I\'m trying to use Ruby 1.9.1 for an embedded scripting language, so that \"end-user\" code gets written in a Ruby block. One issue with this is that I\'d like the users to
Where is thing invoked? Are you inside a class?
You may consider using something like this:
class MyThing
def ret b
@retval = b
end
def thing(*args, &block)
implicit = block.call
value = @retval || implicit
puts "value=#{value}"
end
def example1
thing do
ret 5 * 6
4
end
end
def example2
thing do
5 * 6
end
end
end