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


Groups > comp.lang.ruby > #2302

Autoconvert object from one class1 to other class2 in class1 def

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!weretis.net!feeder5.news.weretis.net!talisker.lacave.net!lacave.net!not-for-mail
From Luk Mus <support@fit4u.su>
Newsgroups comp.lang.ruby
Subject Autoconvert object from one class1 to other class2 in class1 def
Date Tue, 5 Apr 2011 03:02:26 -0500
Organization Service de news de lacave.net
Lines 21
Message-ID <5095fcbac456c1c2b31e5c05fbea960d@ruby-forum.com> (permalink)
NNTP-Posting-Host bristol.highgroove.com
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 7bit
X-Trace talisker.lacave.net 1301990820 99010 65.111.164.187 (5 Apr 2011 08:07:00 GMT)
X-Complaints-To abuse@lacave.net
NNTP-Posting-Date Tue, 5 Apr 2011 08:07:00 +0000 (UTC)
X-Received-From This message has been automatically forwarded from the ruby-talk mailing list by a gateway at comp.lang.ruby. If it is SPAM, it did not originate at comp.lang.ruby. Please report the original sender, and not us. Thanks! For more details about this gateway, please visit: http://blog.grayproductions.net/categories/the_gateway
X-Mail-Count 380963
X-Ml-Name ruby-talk
X-Rubymirror Yes
X-Ruby-Talk <5095fcbac456c1c2b31e5c05fbea960d@ruby-forum.com>
Xref x330-a1.tempe.blueboxinc.net comp.lang.ruby:2302

Show key headers only | View raw


Is it possible to convert from one Class1 to another Class2 within the
functions of the Class1?

Example:

class String
 def to_i!
  self=self.to_i
 end
end

c='1' # c='1' - String
c.to_i! # c=1 - Integer

Previous code is wrong, error:
Can't change the value of self
    self=self.to_i

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

Back to comp.lang.ruby | Previous | NextNext 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