From: Nathan Broadbent Date: 2012-11-13T04:12:03+09:00 Subject: [ruby-core:49261] Re: [ruby-trunk - Bug #7338][Open] loop command doesn't accept begin/end, only { } --e89a8f643544ded6bc04ce511101 Content-Type: text/plain; charset=ISO-8859-1 Hi there, Try 'loop do' instead of 'loop begin' Best, Nathan On Tuesday, 13 November 2012, dwilde1 (Donald Wilde) wrote: > > Issue #7338 has been reported by dwilde1 (Donald Wilde). > > ---------------------------------------- > Bug #7338: loop command doesn't accept begin/end, only { } > https://bugs.ruby-lang.org/issues/7338 > > Author: dwilde1 (Donald Wilde) > Status: Open > Priority: Normal > Assignee: > Category: > Target version: > ruby -v: ruby 1.9.3p286 (2012-10-12 revision 37165) [x86_64-linux] > > > def token_generator > random = Random.new > alpha = Array.new > ('a' .. 'z').each do | c | > alpha << c > end > ('A' .. 'Z').each do | c | > alpha << c > end > numbers = %w{ 0 1 2 3 4 5 6 7 8 9 } > loop begin > unique_string = '' > 0.upto( 19 ) do | n | > if n.even? then > unique_string << alpha[ random.rand( 52 ) ] > else > unique_string << numbers[ random.rand( 10 ) ] > end > end > break unless @sessions.include?( unique_string.to_sym ) > end > unique_string > end > > causes: > > /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:55:in `require': > /home/devel/ISF_Server/Actors/DataProvider.rb:49: syntax error, unexpected > keyword_do_block, expecting keyword_end (SyntaxError) > 0.upto( 19 ) do | n | > ^ > /home/devel/ISF_Server/Actors/DataProvider.rb:72: syntax error, unexpected > keyword_end, expecting $end > from /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:55:in > `require' > from ./server-work.rb:7:in `
' > > but replacing begin/end with { } works. > > > -- > http://bugs.ruby-lang.org/ > > --e89a8f643544ded6bc04ce511101 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi there,

Try 'loop do' instead of 'loop beg= in'


Best,
Nathan

On Tuesday, 13 November 2012, dwilde1 (Donald Wilde) wrote= :

Issue #7338 has been reported by dwilde1 (Donald Wilde).

----------------------------------------
Bug #7338: loop command doesn't accept begin/end, only { }
https:= //bugs.ruby-lang.org/issues/7338

Author: dwilde1 (Donald Wilde)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: ruby 1.9.3p286 (2012-10-12 revision 37165) [x86_64-linux]


def token_generator
=A0 =A0 random =3D Random.new
=A0 =A0 alpha =3D Array.new
=A0 =A0 ('a' .. 'z').each do | c |
=A0 =A0 =A0 alpha << c
=A0 =A0 end
=A0 =A0 ('A' .. 'Z').each do | c |
=A0 =A0 =A0 alpha << c
=A0 =A0 end
=A0 =A0 numbers =3D %w{ 0 1 2 3 4 5 6 7 8 9 }
=A0 =A0 loop begin
=A0 =A0 =A0 unique_string =3D ''
=A0 =A0 =A0 0.upto( 19 ) do | n |
=A0 =A0 =A0 =A0 if n.even? then
=A0 =A0 =A0 =A0 =A0 unique_string << alpha[ random.rand( 52 ) ]
=A0 =A0 =A0 =A0 else
=A0 =A0 =A0 =A0 =A0 unique_string << numbers[ random.rand( 10 ) ]
=A0 =A0 =A0 =A0 end
=A0 =A0 =A0 end
=A0 =A0 =A0 break unless @sessions.include?( unique_string.to_sym )
=A0 =A0 end
=A0 =A0 unique_string
=A0 end

causes:

/usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:55:in `require': /= home/devel/ISF_Server/Actors/DataProvider.rb:49: syntax error, unexpected k= eyword_do_block, expecting keyword_end (SyntaxError)
=A0 =A0 =A0 0.upto( 19 ) do | n |
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0^
/home/devel/ISF_Server/Actors/DataProvider.rb:72: syntax error, unexpected = keyword_end, expecting $end
=A0 =A0 =A0 =A0 from /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:5= 5:in `require'
=A0 =A0 =A0 =A0 from ./server-work.rb:7:in `<main>'

but replacing begin/end with { } works.


--
http://bugs.ruby-l= ang.org/

--e89a8f643544ded6bc04ce511101--