& - FixNum - method doubt

R

Randall Alexander

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

I am just learning Ruby but it looks like the binary intersection of the
true bits. In shorter terms a binary "and" command.
3&6=2
in binary
011&110=010

3&7=3
in binary
011&111=011

7&21=5
in binary
00111&10101=00101

Randy

Hi All,

irb> a=12
irb> a.methods

it contains & method

So I tried like ..
irb> 3&6
=> 2
irb> 3&7
=> 3
irb> 7&21
=> 5

I can't understand how it works. Anyone help me


Thanks,
P.Raveendran
http://raveendran.wordpress.com


--
Randy
http://randallalexander-os.blogspot.com/
http://randallalexander-java.blogspot.com/
http://randallalexander-flex.blogspot.com/
http://randallalexander-ruby.blogspot.com/
 
J

jazzez ravi

Randall said:
I am just learning Ruby but it looks like the binary intersection of the
true bits. In shorter terms a binary "and" command.
3&6=2
in binary
011&110=010

3&7=3
in binary
011&111=011

7&21=5
in binary
00111&10101=00101

Randy

Hi Randy,

Thank you very much for your quick reply.

Also i need help about these methods

+@
-@
=~

Thanks in Advance,
Thanks,
P.Raveendran
http://raveendran.wordpress.com
 
C

Christopher Dicely

2009/3/21 jazzez ravi said:
Hi Leo,

http://www.ruby-doc.org/core-1.9/classes/Fixnum.html also I couldn't
find the methods like,

__id__
__send__
denominator


Methods that appear for instances of a particular class may be defined
in ancestors of that class (or included modules, either of the class
or its ancestors), rather than than in the class itself. In this case
__id__ and __send__ are Kernel methods (probably documented under
Object, rather than Kernel) and denominator is, I think, defined in
Numeric.
 
J

jazzez ravi

Christopher said:
Methods that appear for instances of a particular class may be defined
in ancestors of that class (or included modules, either of the class
or its ancestors), rather than than in the class itself. In this case
__id__ and __send__ are Kernel methods (probably documented under
Object, rather than Kernel) and denominator is, I think, defined in
Numeric.

Hi christopher,

Yes. Finally I got exact solution.Thanks for your help.

Regards,
P.Raveendran
http://raveendran.wordpress.com
 

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

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top