Eva
(Eva)
1
firstly sorry for my bad webmail useragent, so I have to be sending it again.
How to break a block with such the method like each?
for example:
File.new("big.txt").each do |s|
if s =~ /abcd/
puts s
break # is this right?
end
end
Thanks!
Yes, that's correct.
Try it with
"aaa\nbbb\nccc\nabcd\nddd\neee".split("\n").each do |s|
...
if you want a quick test.
···
2010/11/24 Eva <eva54321@sina.com>:
firstly sorry for my bad webmail useragent, so I have to be sending it again.
How to break a block with such the method like each?
for example:
File.new("big.txt").each do |s|
if s =~ /abcd/
puts s
break # is this right?
end
end
Thanks!