[#1026] Is this a bug? — Dave Thomas <Dave@...>

18 messages 2000/01/03

[#1084] Infinite loop — Dave Thomas <Dave@...>

17 messages 2000/01/11

[#1104] The value of while... — Dave Thomas <Dave@...>

24 messages 2000/01/11

[ruby-talk:01197] Question about 'open'

From: Dave Thomas <Dave@...>
Date: 2000-01-30 05:40:31 UTC
List: ruby-talk #1197

If I run:

     f = open("|-", "w+")
     if f == nil
        print "in Child\n"
     else
        print "Got: ", f.gets, "\n"
     end

it outputs

     Got: in Child


However,

     open("|-", "w+") { |f|
       if f == nil
          print "in Child\n"
       else
          print "Got: ", f.gets, "\n"
       end
     }

outputs

     Got: nil



What am I misunderstanding here?



Thanks

Dave

In This Thread

Prev Next