# Newbie question about Pickaxe example

**URL:** <https://www.ruby-forum.com/t/newbie-question-about-pickaxe-example/47952>\
**Category:** Ruby\
**Created:** [November 15, 2005, 1:53pm UTC](https://www.ruby-forum.com/t/newbie-question-about-pickaxe-example/47952 "2005-11-15T13:53:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![carmineaskme](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/838e76/32.png) [@carmineaskme](https://www.ruby-forum.com/u/carmineaskme)\
**Post date:** [November 15, 2005, 1:53pm UTC](https://www.ruby-forum.com/t/newbie-question-about-pickaxe-example/47952/1 "2005-11-15T13:53:04Z")

</div>

Hi to everyone,

I’m just approaching ruby (so far I like it) coming from Python and  
other OO languages.

I’ve bought the new edition of the famous “Pickaxe” book and I’m having  
a little difficulties understanding a piece of code.

There’s a paragraph (on page 354 for those who have that book) about  
“Module Definitions” which contains the following snippet of code:

CONST=“outer”  
module Mod  
CONST=1  
def Mod.method1()  
CONST + 1  
end  
end

module Mod::Inner  
def (Mod::Inner).method2()  
CONST + " scope"  
end  
end

well, this last part is the one causing me difficulties.

“::” is the scope resolutor, and so far so good, but “Mod::Inner” what  
is it?  
“Inner” ought to be a constant judging from the name conventions.  
Is it a predefinite one, or what?

I imagine that the definition under “Mod::Inner” are meant to insert  
“method2” in the module “Mod”. Just can’t figure why “Mod::Inner”.

Thanks in advance for your help.

Regards,  
Carmine M.

---

<div class="post-metadata">

**Author:** ![carmineaskme](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/838e76/32.png) [@carmineaskme](https://www.ruby-forum.com/u/carmineaskme)\
**Post date:** [November 15, 2005, 2:02pm UTC](https://www.ruby-forum.com/t/newbie-question-about-pickaxe-example/47952/2 "2005-11-15T14:02:07Z")

</div>

> > > > > “C” == Carmine M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

C\> module Mod::Inner

here it define the module Inner under the module Mod

C\> def (Mod::Inner).method2()

it define a method for this module (Mod::Inner)

C\> CONST + " scope"  
C\> end  
C\> end

it’s written like this, to see the difference with this

module Mod  
module Inner  
def self.method2  
CONST + “scope”  
end  
end  
end

Mod::Inner.method2 # in `+': String can’t be coerced into Fixnum

Guy Decoux

---

<div class="post-metadata">

**Author:** ![carmineaskme](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/838e76/32.png) [@carmineaskme](https://www.ruby-forum.com/u/carmineaskme)\
**Post date:** [November 15, 2005, 2:14pm UTC](https://www.ruby-forum.com/t/newbie-question-about-pickaxe-example/47952/3 "2005-11-15T14:14:13Z")

</div>

Hi Guy,

Thanks for your clarification. It’s clear now.

Regards,  
Carmine M.
