Forum: Ruby & - FixNum - method doubt

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Da22709962fc0cf31068e779c78ab6be?d=identicon&s=25 Raveendran .P (jazzezravi)
on 2009-03-21 06:07
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
E5b58a74b075e283aaa6250a8cddf8ed?d=identicon&s=25 Randall Alexander (Guest)
on 2009-03-21 06:24
(Received via mailing list)
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
Da22709962fc0cf31068e779c78ab6be?d=identicon&s=25 Raveendran .P (jazzezravi)
on 2009-03-21 06:32
Randall Alexander wrote:
> 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
Da22709962fc0cf31068e779c78ab6be?d=identicon&s=25 Raveendran .P (jazzezravi)
on 2009-03-21 06:38
Hi Randy,

And few more ..

 +@
 -@
 =~
 >>
[]
^
__id__
__send__

Waiting for your reply



Thanks in Advance,
Thanks,
P.Raveendran
http://raveendran.wordpress.com
87ef5d1e14b148eb596433bc17ffe690?d=identicon&s=25 Leo (Guest)
on 2009-03-21 07:16
(Received via mailing list)
Da22709962fc0cf31068e779c78ab6be?d=identicon&s=25 Raveendran .P (jazzezravi)
on 2009-03-21 09:51
Leo wrote:
>> And few more ..
>
> http://www.ruby-doc.org/core-1.9/classes/
> http://www.ruby-doc.org/core-1.9/classes/Fixnum.html

Hi Leo,

Thanks for your reply.

I am using Ruby 1.86 so http://www.ruby-doc.org/core/ will help me.


Regards,
P.Raveendran
http://raveendran.wordpress.com
Da22709962fc0cf31068e779c78ab6be?d=identicon&s=25 Raveendran .P (jazzezravi)
on 2009-03-21 10:19
Leo wrote:
>> And few more ..
>
> http://www.ruby-doc.org/core-1.9/classes/
> http://www.ruby-doc.org/core-1.9/classes/Fixnum.html

Hi Leo,

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

__id__
__send__
denominator

etc..,

Please help to me once again..


Regards,
P.Raveendran
http://raveendran.wordpress.com
D7463bd611f227cfb2ef4da4a978a203?d=identicon&s=25 Christopher Dicely (Guest)
on 2009-03-21 10:53
(Received via mailing list)
2009/3/21 jazzez ravi <jazzezravi@gmail.com>:
>
> __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.
Da22709962fc0cf31068e779c78ab6be?d=identicon&s=25 Raveendran .P (jazzezravi)
on 2009-03-21 11:27
Christopher Dicely wrote:
> 2009/3/21 jazzez ravi <jazzezravi@gmail.com>:
>>
>> __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.

Hi christopher,

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

Regards,
P.Raveendran
http://raveendran.wordpress.com
Da22709962fc0cf31068e779c78ab6be?d=identicon&s=25 Raveendran .P (jazzezravi)
on 2009-03-30 12:03
Hi All,

>> 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.

I spent more time to find the solution for all methods. So I created one
document which contains all the methods for that particular class.

Now it is available here

Fixnum:

http://raveendran.wordpress.com/2009/03/25/ruby-fi...

String:

http://raveendran.wordpress.com/2009/03/25/ruby-fi...


 Regards,
P.Raveendran
 http://raveendran.wordpress.com
Da22709962fc0cf31068e779c78ab6be?d=identicon&s=25 Raveendran .P (jazzezravi)
on 2009-03-30 12:04
Hi all,


one small change

String :

http://raveendran.wordpress.com/2009/03/30/ruby-st...


Regards,
P.Raveendran
http://raveendran.wordpress.com
This topic is locked and can not be replied to.