[#1816] Ruby 1.5.3 under Tru64 (Alpha)? — Clemens Hintze <clemens.hintze@...>

Hi all,

17 messages 2000/03/14

[#1989] English Ruby/Gtk Tutorial? — schneik@...

18 messages 2000/03/17

[#2241] setter() for local variables — ts <decoux@...>

18 messages 2000/03/29

[ruby-talk:02280] Re: Ruby Lang Ref Manual 1.4 Question: $= & is nil not false?

From: Dave Thomas <Dave@...>
Date: 2000-03-30 21:23:00 UTC
List: ruby-talk #2280
schneik@us.ibm.com writes:

>           String comparison. If the value of the variable $= is not false,
> comparison done by case-insensitive.
> ============================================
> 
> I just want to be sure that this is the same as saying "If the value ... is
> not nil, ....".

Not quite. falsity (?) is 'nil' or 'false' (or the deprecated
'FALSE').

The interpreter normaly checks for 'truth' using the RTEST macro,
which returns the C equivalent of TRUE for every value apart from nil
and false/FALSE.

> It might be nice to have standard but automagically localized
> versions of these variables, perhaps $$=, $$/, $$\, and so on, that
> would locally over-ride their global counterparts.  Perhaps then
> Ruby strict compile mode could prohibit you from changing the global
> control variables, but allow the use of the localized control
> variables.

We could use 'local($/)'  ;-)


As a temporary hack, I guess you could define a class which pushed and 
popped values, and protect code that changes them in a
begin/ensure/end block.

  begin
    saver = Saver.new(:$/, :$\)
    # ..
    # .. stuff
  ensure
    saver.pop
  end

But that's pretty messy.


Dave

In This Thread