From: Dave Thomas Date: 2001-05-04T23:33:41+09:00 Subject: [ruby-talk:14639] Re: access to $_ for methods we write "Guy N. Hurst" writes: > Hi, > > I have tried this: > > def foo(x=$_) > puts x > end > > $_ = "bar" > foo($_) # => bar > foo # => nil > print # => bar > > Why is it that the #print method is allowed > to have access to $_ as its default, but methods > we write aren't? Or is there something I am missing? Guy: If you want the 'global' $_, you can always do: def foo(x=eval("$_", TOPLEVEL_BINDING)) puts x end However, this won't always emulate the behavior of (say) print. Dave