Method: Random#initialize_copy

Defined in:
random.c

#initialize_copy(orig) ⇒ Object

:nodoc:



803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
# File 'random.c', line 803

static VALUE
rand_mt_copy(VALUE obj, VALUE orig)
{
    rb_random_mt_t *rnd1, *rnd2;
    struct MT *mt;

    if (!OBJ_INIT_COPY(obj, orig)) return obj;

    rnd1 = get_rnd_mt(obj);
    rnd2 = get_rnd_mt(orig);
    mt = &rnd1->mt;

    *rnd1 = *rnd2;
    mt->next = mt->state + numberof(mt->state) - mt->left + 1;
    return obj;
}