ngomong bahasa awam :)

di ruby variable itu nyimpen object, apa itu object numerik, string, array
etc...
nah untuk assigmentnya pake =, tapi inga' kalo yang di assignment adalah
variable(tok tanpa embel embel .clone etc..) maka
dia akan reference-kan

On 5/23/07, Yohanes Santoso <[EMAIL PROTECTED]> wrote:
>
>   "julius sirait" <[EMAIL PROTECTED] <sirait.milis%40gmail.com>>
> writes:
>
> > On 5/23/07, Widi Harsojo <[EMAIL PROTECTED] <wharsojo%40gmail.com>>
> wrote:
> >>
> >>
> >>
> >>
> >>
> >>
> >> irb(main):071:0> 1.class
> >> => Fixnum
> >> irb(main):072:0> 121312312312.class
> >> => Bignum
> >> irb(main):073:0>
> >>
> >
> > yoi. nah, kenapa untuk nilai yang sama, object_id nya sama. tebakan
> > nya kan karna class method new gak ada. tapi kenapa untuk bignum,
> > object_id nya beda padahal:
> >
> > irb(main):002:0> Fixnum.new
> > NameError: undefined method `new' for Fixnum:Class
> > from (irb):2
> > irb(main):003:0> Bignum.new
> > NameError: undefined method `new' for Bignum:Class
> > from (irb):3
> >
> > --
> > Julius Sirait
>
> Itu implementation artifact untuk performance reason:
>
> http://www.rubycentral.com/faq/rubyfaq-9.html
> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
> 9.3 What is the difference between an immediate value and a reference?
>
> Fixnum, true, nil, and false are implemented as immediate values. With
> immediate values, variables hold the objects themselves, rather than
> references to them.
>
> Singleton methods cannot be defined for such objects. Two Fixnums of
> the same value always represent the same object instance, so (for
> example) instance variables for the Fixnum with the value "one" are
> shared between all the "ones" is the system. This makes it impossible
> to define a singleton method for just one of these.
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> YS.
>  
>


[Non-text portions of this message have been removed]

Kirim email ke