Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #2305

Re: Autoconvert object from one class1 to other class2 in class1 def

From Brian Candler <b.candler@pobox.com>
Newsgroups comp.lang.ruby
Subject Re: Autoconvert object from one class1 to other class2 in class1 def
Date 2011-04-05 03:46 -0500
Organization Service de news de lacave.net
Message-ID <3962d67dedc7aa2c534540d17939bf1a@ruby-forum.com> (permalink)
References <5095fcbac456c1c2b31e5c05fbea960d@ruby-forum.com>

Show all headers | View raw


Luk Mus wrote in post #990946:
> Is it possible to convert from one Class1 to another Class2 within the
> functions of the Class1?

No, an object cannot change its class. All you can do is return a new 
object of a different class.

> or how get name of variable in class method?

That's not possible either. The same object could be pointed to by many 
variables (local and/or global and/or instance), or by none. For 
example, maybe the only reference to the object is as a value in a Hash.

-- 
Posted via http://www.ruby-forum.com/.

Back to comp.lang.ruby | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Autoconvert object from one class1 to other class2 in class1 def Luk Mus <support@fit4u.su> - 2011-04-05 03:02 -0500
  Re: Autoconvert object from one class1 to other class2 in class1 def Luk Mus <support@fit4u.su> - 2011-04-05 03:19 -0500
  Re: Autoconvert object from one class1 to other class2 in class1 def Brian Candler <b.candler@pobox.com> - 2011-04-05 03:46 -0500
    Re: Autoconvert object from one class1 to other class2 in class1 def Luk Mus <support@fit4u.su> - 2011-04-05 04:15 -0500
      Re: Autoconvert object from one class1 to other class2 in class1 def Brian Candler <b.candler@pobox.com> - 2011-04-05 07:41 -0500
      Re: Autoconvert object from one class1 to other class2 in class1 def Adam Prescott <adam@aprescott.com> - 2011-04-05 07:50 -0500
      Re: Autoconvert object from one class1 to other class2 in class1 def Robert Klemme <shortcutter@googlemail.com> - 2011-04-05 07:56 -0500

csiph-web