TIL parameter destructuring

Skip to first unread message

William Clifford

Feb 25, 2016, 12:38:00 PM2/25/16
to pdxruby-beginners

irb(main):001:0> def foo((a,b),c)
irb(main):002:1> [a,b,c]
irb(main):003:1> end
=> :foo
irb(main):004:0> foo [1,2],3
=> [1, 2, 3]

Jesse Cooke

Feb 25, 2016, 1:39:21 PM2/25/16
to pdxruby-beginners
Neat! I've never seen that in use, but cool to know it's there.

I'm guessing the recommendation would be to pass in an object, call a method, but this looks handy.

You received this message because you are subscribed to the Google Groups "pdxruby-beginners" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pdxruby-beginn...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
0 new messages