[#1263] Draft of the updated Ruby FAQ — Dave Thomas <Dave@...>

33 messages 2000/02/08

[#1376] Re: Scripting versus programming — Andrew Hunt <andy@...>

Conrad writes:

13 messages 2000/02/15

[#1508] Ruby/GTK and the mainloop — Ian Main <imain@...>

17 messages 2000/02/19
[#1544] Re: Ruby/GTK and the mainloop — Yasushi Shoji <yashi@...> 2000/02/23

Hello Ian,

[#1550] Re: Ruby/GTK and the mainloop — Ian Main <imain@...> 2000/02/23

On Wed, Feb 23, 2000 at 02:56:10AM -0500, Yasushi Shoji wrote:

[#1516] Ruby: PLEASE use comp.lang.misc for all Ruby programming/technical questions/discussions!!!! — "Conrad Schneiker" <schneiker@...>

((FYI: This was sent to the Ruby mail list.))

10 messages 2000/02/19

[#1569] Re: Ruby: constructors, new and initialise — Yukihiro Matsumoto <matz@...>

The following message is a courtesy copy of an article

12 messages 2000/02/25

[ruby-talk:01385] Re: Say hi (bis)

From: Dave Thomas <Dave@...>
Date: 2000-02-15 14:33:13 UTC
List: ruby-talk #1385
pixel_@mandrakesoft.com writes:

> one other thing for which it was missing is giving a function instead of a
> block, eg:  
> 
> def f(n); [n,n+1]; end; 
> #l.collect \f 
>   #instead of 
> l.collect{|n| f(n)}

You could use a Proc for this:

  fn = proc {|n| [n, n+1] }

or you can use Object.method to return a Method object for a named
method (optionally converting it to a Proc object:

  fn = self.method(:f).to_proc

> > |-- ?? can't redefine a function
> > 
> > you can.
> 
> i was thinking of:
> 
> # !warning! perl here
> sub f { 1 }
> {  
>   my $f = \&f;
>   *f = sub { print "f called\n"; goto &f };
> }

alias oldF f
def f(*args)
  puts "f called"
  oldF(*args)
end


Renaming using 'alias' is one of the joys of Ruby.

> > |- you have to initialize before doing +=
> > 
> > Explicit initialization is good thing I think.
> > 
> > You can avoid them by
> > 
> >   def <<nil
> >     def +(other)
> >       other
> >     end
> >   end
> 
> i don't quite understand that one :(
> 
> i'd have said:
> 
> class NilClass
>   def +(other); other; end
> end

'nil' is the only instantiation of NilClass, so the two are
effectively the same.



Regards

Dave

In This Thread