Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save joonyou/5025499 to your computer and use it in GitHub Desktop.
Save joonyou/5025499 to your computer and use it in GitHub Desktop.
Ruby 2.0 – Getting Started & Named Parameters
def foo(with:"default", delegate:String, selector:"to_s")
puts "with: #{with}"
puts "delegate: #{delegate.class.to_s}"
puts "result: #{delegate.send(selector)}"
end
def bar; puts "hello from Bar";end
foo with:"Joon", delegate:self, selector:"bar"
@SeriousM
Copy link

Hi.

The line def bar; puts "hello from Bar";end contains a puts which sends the output to the console, not to the caller method.

Thats why it doesn't work as it should.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment