[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ruby-talk
Subject:    Re: [NEWBIE] Extract all occurences from a text
From:       gabriele renzi <surrender_it () rc1 ! vip ! ukl ! yahoo ! com>
Date:       2004-04-23 13:54:05
Message-ID: aj7i80t7cqdbr0ldl91oev48surr73ch4e () 4ax ! com
[Download RAW message or body]

il Fri, 23 Apr 2004 15:43:24 +0200, Kristof Bastiaensen
<kristof@vleeuwen.org> ha scritto::

>On Fri, 23 Apr 2004 05:08:00 -0700, David Alan Black wrote:
>
>>> 
>>> you could simply do:
>>> 
>>> lines=[]
>
>This line has no effect, the Array will be discarded
>at the next expression
>
>>> open(filename) do |f|
>>>  lines= f.grep your_regexp
>>> end
>> 

just try it ;P

If you do not initialize a variable outside of a block it will be
discarded when the block ends. 

This will change in ruby2 and work like you expect (I expect the
behaviour it has ATM)

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic