I am interested whether this can be done and what the syntax would be. I’m at:
def say_it
puts "before"
yield("something here")
puts "after"
end
say_it do |val|
puts "here is " + val
yield("other things") # ???
end
thinking probably no but maybe if block gets converted to a Proc?
thx in advance
A
yieldonly makes sense from within a method that takes a block.And yes, they can nest. Note that:
yield) are strictly tied to methods.Example: