Skip to content

Instantly share code, notes, and snippets.

@jdx
Created November 13, 2012 21:26
Show Gist options
  • Save jdx/4068500 to your computer and use it in GitHub Desktop.
Save jdx/4068500 to your computer and use it in GitHub Desktop.
ruby array appends w/ method parameters
dickeyxxx@dickey-mbp ~/proj/vagrant 2.0.0-dev (master ✘)✹✚✭
✗✗✗ irb
irb(main):001:0> RUBY_VERSION
=> "2.0.0"
irb(main):002:0> def foo(arr: [])
irb(main):003:1> p arr
irb(main):004:1> arr << 'x'
irb(main):005:1> end
=> nil
irb(main):006:0> foo
[]
=> ["x"]
irb(main):007:0> foo
[]
=> ["x"]
irb(main):008:0> foo
[]
=> ["x"]
irb(main):009:0> foo
[]
=> ["x"]
irb(main):010:0> foo
[]
=> ["x"]
irb(main):011:0>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment