On Wed, Apr 21, 2010 at 7:55 AM, tilde [email protected]

wrote:

Hi there, first time arond here for me, and first step with ruby ^^

well, i come with a simple (maybe stupid) question:

http://sprunge.us/BjJP?rb

(copying it here since it’s small):

1 #! /usr/bin/env ruby1.9

2

3 module Math

4 private :sqrt

5 end

6

7 puts Math.sqrt(9)

why this simple source doesn’t do what is expected? (modify the visibility

of sqrt module)

Because sqrt is a module method:

irb(main):001:0> module Math

irb(main):002:1> class << self

irb(main):003:2> private :sqrt

irb(main):004:2> end

irb(main):005:1> end

=> #Class:Math

irb(main):006:0> Math.sqrt(9)

NoMethodError: private method `sqrt’ called for Math:Module

from (irb):6

from :0

Jesus.