I'm working with a method that takes a block as an argument. I'm new to Ruby and Blocks, so I don't quite understand how I would go about creating a Block and passing it to the method. Can you please provide me an example of how you would create a block and pass it as an argument?
Update: Here is an example of the method that I am trying to call:
def exec!(commands, options=nil, &block)
# method code here
# eventually it will execute the block if one was passed
end
Here is how I am currently calling this method:
@result = ssh.exec!("cd /some/dir; ls")
How do I pass a block as the third argument to the exec! method?
do/endor{}to create the block. If it yields something to the block, you'd use vertical bars|foo|to access whatever it yields in your block, like theeachexample in my comment.