def foo(thing, block): thing = "cruel " + thing block(thing) # like `yield thing' or 'block.call' in ruby def bar(thing): return "hello " + thing foo('world', bar) # or: foo('world', lambda x: "hello " + x)
def foo(thing) yield thing end foo('world') { |thing| "hello " + thing }