Two things about Ruby programming:
- A variable is stored in memory (in Ruby’s “ObjectSpace”) as long as the variable is alive / referenced by something.
- To get a value from a function/method, you need to return it with
return (in Ruby usually the last expression is automatically returned).
That means for 1.) you type in and evaluate only the variable name to get a textual version of the variable’s value (as the default Window → Ruby Console does). According to the documentation (
Array(Geom::Point3d, Array<Sketchup::Drawingelement>)?), you would expect that
raytest either returns
nil (check for it, if the ray hits nothing) or two objects, an intersection point and an array of the drawing elements that have been hit. You can nicely visualize the objects that your variables reference by using for example Ruby Console+, it may have helped to understand where the points and drawing elements are located in the model.
For 2.) there is the special case that you are evaluating a code snippet that is not wrapped in a function/method (and thus
return is invalid), but the last value should be returned and printed by the Ruby Code Editor. Some consoles of some languages (like Python) do not print
nil, but you should in any case see something for other values.