[solved] a small syntax problem
-
hello,
when i run this code (with 10 faces and NO GROUPS in the selection)
@selection.each { |@entity| if @entity.is_a?(Sketchup;;Face) puts "face" elsif @entity.is_a?(Sketchup;;Group) puts "group" end }
the "face" is printed 10 times and
the "group" is printed 10 timesin the console.what is wrong with my elsif condition?
thanx a lot
stan -
Dont use an instance variable in the iterator
@selection.each { |@entity|
Should be
@selection.each { |entity|
Otherwise I'm totally misinformed.
The values get stored in the instance variables during the session wheras the
entity variable gets executed in the iterators scope only, if that makes sense what I say.. -
hello jorlan,
thanx for the tip.
i corrected it, so the code is clearer (i have to trasport this value to another method, so i assigned an independent variable to ,entity'.)
stan -
No problem, glad to help if the tip worked.
Advertisement