From ddjolley at gmail.com Mon Mar 5 09:43:42 2007 From: ddjolley at gmail.com (Doug Jolley) Date: Mon, 5 Mar 2007 09:43:42 -0800 Subject: [OCLUG-devel] Ruby - Default Method Args Message-ID: Are there any Ruby programmers on the list that can explain to me why this snippet of code: def foo(a,b="four",c) puts("Arg1: #{a}") puts("Arg2: #{b}") puts("Arg3: #{c}") end foo('one','two','three') produces these errors: ./test1.rb:3: syntax error, unexpected ')', expecting '=' ./test1.rb:7: syntax error, unexpected kEND, expecting $end instead of this result: Arg1: one Arg2: two Arg3: three Thanks for any input. ... doug -------------- next part -------------- An HTML attachment was scrubbed... URL: http://localhost.localdomain/pipermail/oclug-devel/attachments/20070305/1becf2e0/attachment.html From michael.elkins at gmail.com Mon Mar 5 10:50:34 2007 From: michael.elkins at gmail.com (Michael Elkins) Date: Mon, 5 Mar 2007 10:50:34 -0800 Subject: [OCLUG-devel] Ruby - Default Method Args In-Reply-To: References: Message-ID: <404f03220703051050l2d5fddfbg81e4ee386572adbb@mail.gmail.com> On 3/5/07, Doug Jolley wrote: > > > > def foo(a,b="four",c) > > You either need to specify a default argument for 'c', or move b to the end. You can't have any arguments without defaults occurring after an argument with a default value. Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: http://localhost.localdomain/pipermail/oclug-devel/attachments/20070305/ff7c99ac/attachment.html From ddjolley at gmail.com Mon Mar 5 11:56:53 2007 From: ddjolley at gmail.com (Doug Jolley) Date: Mon, 5 Mar 2007 11:56:53 -0800 Subject: [OCLUG-devel] Ruby - Default Method Args In-Reply-To: <404f03220703051050l2d5fddfbg81e4ee386572adbb@mail.gmail.com> References: <404f03220703051050l2d5fddfbg81e4ee386572adbb@mail.gmail.com> Message-ID: That certainly explains it. Thanks a batch. ... doug -------------- next part -------------- An HTML attachment was scrubbed... URL: http://localhost.localdomain/pipermail/oclug-devel/attachments/20070305/2b82bcef/attachment.html