Access Control confusion

C

Chang Min Jeon

[Note: parts of this message were removed to make it a legal post.]

I read Ruby User's Guide <http://www.rubyist.net/~slagell/ruby/>
created by Yukihiro Matsumoto

http://www.rubyist.net/~slagell/ruby/accesscontrol.html

and i have a question about access control.
Access Control section explain method following code.
* def square(n)*
|* n * n*
|* end*

Object class has square method.

But it is not allowed access of square method following document.

We are not allowed to explicitly apply the method to an object:

ruby>* "fish".square(5)*
*ERR: (eval):1: private method `square' called for "fish":String*

But it is operated when i write code above in ruby 1.8.7

What is the matter ?
wrong document ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top