KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Setting a default value for a splat argument gives an error: 1.9.3-p374 :001 > def a b, *c = nil 1.9.3-p374 :002?> end SyntaxError: (irb):1: syntax error, unexpected '=', expecting ';' or '\n' def a b, *c = nil ^ from /Users/me/.rvm/rubies/ruby-1.9.3-p374/bin/irb:16:in `<main>' Some variations I tried that don't work either: 1.9.3-p374 :003 > def a b, *c = [] 1.9.3-p374 :005 > def a b, (*c) = nil 1.9.3-p374 :007 > def a b, (*c = []) 1.9.3-p374 :009 > def a b, (*c = [1,2,3]) 1.9.3-p374 :011 > def a b, *c = [1,2,3] I don't see an indeterminacy issue here, so it seems like it should be possible. Related: Why non-explicit splat param plus default param is wrong syntax for method definition in Ruby 1.9?
Tags (comma-separated)
Save Edits
Cancel