From: Steven Ketcham Date: 2003-06-01T05:45:43+09:00 Subject: Re: newbie questions I am probably confusing concepts but in C++ you can pass a parameter by reference, pointer or value. Copy constructors, variable scope and things like that are very important to track. If I pass a complex object by value to a function, the copy of the object will automatically run it's destructor when the function returns. This could be devasting when working with file or database handles. How are objects handled when passed to a function with Ruby? Thanks! 5/31/2003 1:11:21 PM, Michael Neumann wrote: >On Sun, Jun 01, 2003 at 02:00:29AM +0900, Steven Ketcham wrote: >> >> Moving from C++ >> ...snip... >There are not type declarations in Ruby. But you can freeze object, by >calling it's freeze method. Those objects cannot be modified, but it's >up to the called to do this! Another way would be to copy the objects >at the top of the method (using it's dup method). > >Regards, > > Michael > >-- >ruby -r complex -e 'c,m,w,h=Complex(-0.75,0.136),50,150,100;puts "P6\n#{w} #{h}\n255";(0...h).each{|j|(0...w).each{|i| >n,z=0,Complex(.9*i/w,.9*j/h);while n<=m&&(z-c).abs<=2;z=z*z+c;n+=1 end;print [10+n*15,0,rand*99].pack("C*")}}'|display >