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


Groups > comp.lang.ruby > #4106

Question regarding interaction between modules and classes

Path csiph.com!x330-a1.tempe.blueboxinc.net!aioe.org!news.dougwise.org!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!talisker.lacave.net!lacave.net!not-for-mail
From Geometric Patterns <geometric.patterns@gmail.com>
Newsgroups comp.lang.ruby
Subject Question regarding interaction between modules and classes
Date Sat, 7 May 2011 22:02:48 -0500
Organization Service de news de lacave.net
Lines 37
Message-ID <fb5b1151925c37ab1b0160d82a746ea4@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 1304823873 55381 65.111.164.187 (8 May 2011 03:04:33 GMT)
X-Complaints-To abuse@lacave.net
NNTP-Posting-Date Sun, 8 May 2011 03:04:33 +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 382816
X-Ml-Name ruby-talk
X-Rubymirror Yes
X-Ruby-Talk <fb5b1151925c37ab1b0160d82a746ea4@ruby-forum.com>
Xref x330-a1.tempe.blueboxinc.net comp.lang.ruby:4106

Show key headers only | View raw


Hi,

In the code below, is there a way to learn @foo from $bar_one
using $bar_two?

Many thanks in advance!!


----------------

#!/usr/bin/ruby -w

module Foo
   def setup
      @foo = self.object_id
   end
   def foo
      return @foo
   end
end

class Bar
   include Foo
end

$bar_one = Bar.new
$bar_one.setup
p $bar_one.foo  # => 2148224640

$bar_two = Bar.new
p $bar_two.foo  # => warning: instance variable @foo not initialized

----------------

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

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


Thread

Question regarding interaction between modules and classes Geometric Patterns <geometric.patterns@gmail.com> - 2011-05-07 22:02 -0500
  Re: Question regarding interaction between modules and classes Josh Cheek <josh.cheek@gmail.com> - 2011-05-07 22:31 -0500
  Re: Question regarding interaction between modules and classes 7stud -- <bbxx789_05ss@yahoo.com> - 2011-05-07 22:34 -0500

csiph-web