2010/5/4 Kerwin Franks <>:
> Hello, i need some help here, when i run the following code i get the
> error below. Why is that, according to the textbook it should work, also
> looked it up in the cookbook, no luck there too. Thanks in advance.
>
> def split_apart(first, *splat, last)
> =A0puts "first: #{first.inspect}, splat: #{splat.inspect}, " +
> =A0 =A0 =A0 "last: #{last.inspect}"
> =A0end
>
> split_apart(1,2)
> split_apart(1, 2, 3)
>
> Error:
>
> /home/gribota1/NetBeansProjects/Analyzer/lib/rubymethods.rb:32: syntax
> error, unexpected tIDENTIFIER, expecting tAMPER or '&'
> def split_apart(first, *splat, last)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ^
10:49:13 test_2$ allruby -ce 'def s(a,*b,c) end'
CYGWIN_NT-5.1 padrklemme1 1.7.5(0.225/5/3) 2010-04-12 19:07 i686 Cygwin
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3 D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
ruby 1.8.7 (2008-08-11 patchlevel 72) [i386-cygwin]
-e:1: syntax error, unexpected tIDENTIFIER, expecting tAMPER or '&'
def s(a,*b,c) end
^
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3 D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
ruby 1.9.1p378 (2010-01-10 revision 26273) [i386-cygwin]
Syntax OK
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3 D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
jruby 1.4.0 (ruby 1.8.7 patchlevel 174) (2009-11-02 69fbfa3) (Java
HotSpot(TM) Client VM 1.6.0_20) [x86-java]
SyntaxError in -e:1: , unexpected tIDENTIFIER
def s(a,*b,c) end
^
11:16:32 test_2$
Cheers
robert
--=20
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/