N
naPOLeon
Hello,
I'm a just beginner to ruby and impressed by the possibility to test
code in irb. Today I wrote a line of code in irb and it behaved as I
expected. But when I inserted it in my program and executed with ruby,
the code-block didn't worke. Maybe you could tell me why.
The line
a.scan(reg_exp).each {|w| print "#{w.to_s}: "; a.sub!(reg_exp,
gets.chomp)}
It asked me in irb depending on the size of 'a' for some input and
replaced a part (I used the Regular Expression /<\w*>/) of the string
'a' with my input.
But if I use this line in a program, the part 'gets.chomp' seems to be
ignored. The result is no change on String 'a'.
I've no explanation for this strange behaviour, I hope you can give me
a hint. Maybe the whole line is rubbish and there is a lot better way
to do the job?
Thanks,
naPOLeon
I'm a just beginner to ruby and impressed by the possibility to test
code in irb. Today I wrote a line of code in irb and it behaved as I
expected. But when I inserted it in my program and executed with ruby,
the code-block didn't worke. Maybe you could tell me why.
The line
a.scan(reg_exp).each {|w| print "#{w.to_s}: "; a.sub!(reg_exp,
gets.chomp)}
It asked me in irb depending on the size of 'a' for some input and
replaced a part (I used the Regular Expression /<\w*>/) of the string
'a' with my input.
But if I use this line in a program, the part 'gets.chomp' seems to be
ignored. The result is no change on String 'a'.
I've no explanation for this strange behaviour, I hope you can give me
a hint. Maybe the whole line is rubbish and there is a lot better way
to do the job?
Thanks,
naPOLeon