[#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:01942] no Fixnum#new ?

From: Quinn Dunkan <quinn@...>
Date: 2000-03-17 00:42:14 UTC
List: ruby-talk #1942
Ok, I can add methods to a built-in class well enough (yes I know about succ,
it's just an example):

irb(main):001:0> class Integer
irb(main):002:1>     def inc() self + 1 end
irb(main):003:1> end
nil
irb(main):004:0> 5.inc
6

But how could I make a class Myint that derives Integer?  If I derive Integer
and do Myint.new, what I get is not so useful since Integer is an abstract
base.  But if I derive Fixnum, I now have no way to create Myints since
Fixnums and Bignums don't have new constructors...

Iterestingly enough, the other classes with 'syntax constructors', String and
Array, do have new methods.

Also, is it considered good ruby form to modify existing classes?  It seems
scary to me because it's like modifying global values: all the sudden, the
order you import modules becomes important, and all the other nastiness that
mutable globals bring to the table...

Also, to add to the 'initialize' vs 'initialise' debate, I like 'init' the
best.  Less typing.  Doesn't annoy British people.  Just as obvious meaning.  
What more could you want?

In This Thread

Prev Next