[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

& - FixNum - method doubt

Raveendran Jazzez

3/21/2009 5:04:00 AM

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.wor...
--
Posted via http://www.ruby-....

10 Answers

Randall Alexander

3/21/2009 5:21:00 AM

0

[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

On Sat, Mar 21, 2009 at 1:04 AM, jazzez ravi <jazzezravi@gmail.com> wrote:

> 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.wor...
> --
> Posted via http://www.ruby-....
>
>


--
Randy
http://randallalexander-os.blo...
http://randallalexander-java.blo...
http://randallalexander-flex.blo...
http://randallalexander-ruby.blo...

Raveendran Jazzez

3/21/2009 5:30:00 AM

0

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.wor...
--
Posted via http://www.ruby-....

Raveendran Jazzez

3/21/2009 5:35:00 AM

0

Hi Randy,

And few more ..

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

Waiting for your reply



Thanks in Advance,
Thanks,
P.Raveendran
http://raveendran.wor...

--
Posted via http://www.ruby-....

-lim-

3/21/2009 6:13:00 AM

0

Raveendran Jazzez

3/21/2009 8:48:00 AM

0

Leo wrote:
>> And few more ..
>
> http://www.ruby-doc.org/core-1....
> http://www.ruby-doc.org/core-1....Fixnum.html

Hi Leo,

Thanks for your reply.

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


Regards,
P.Raveendran
http://raveendran.wor...
--
Posted via http://www.ruby-....

Raveendran Jazzez

3/21/2009 9:17:00 AM

0

Leo wrote:
>> And few more ..
>
> http://www.ruby-doc.org/core-1....
> http://www.ruby-doc.org/core-1....Fixnum.html

Hi Leo,

http://www.ruby-doc.org/core-1....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.wor...
--
Posted via http://www.ruby-....

Christopher Dicely

3/21/2009 9:50:00 AM

0

2009/3/21 jazzez ravi <jazzezravi@gmail.com>:
> Leo wrote:
>>> And few more ..
>>
>> http://www.ruby-doc.org/core-1....
>> http://www.ruby-doc.org/core-1....Fixnum.html
>
> Hi Leo,
>
> http://www.ruby-doc.org/core-1....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.

Raveendran Jazzez

3/21/2009 10:25:00 AM

0

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.wor...
--
Posted via http://www.ruby-....

Raveendran Jazzez

3/30/2009 10:03:00 AM

0

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.wor.../2009/03/25/ruby-fixnum-docu...

String:

http://raveendran.wor.../2009/03/25/ruby-fixnum-docu...


Regards,
P.Raveendran
http://raveendran.wor...

--
Posted via http://www.ruby-....

Raveendran Jazzez

3/30/2009 10:04:00 AM

0

Hi all,


one small change

String :

http://raveendran.wor.../2009/03/30/ruby-string-docu...


Regards,
P.Raveendran
http://raveendran.wor...

--
Posted via http://www.ruby-....