Project

General

Profile

Actions

Bug #7338

closed

loop command doesn't accept begin/end, only { }

Added by dwilde1 (Donald Wilde) over 11 years ago. Updated over 11 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.3p286 (2012-10-12 revision 37165) [x86_64-linux]
Backport:
[ruby-core:49260]

Description

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.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0