Method: Module#attr_writer

Defined in:
object.c

#attr_writer(symbol, ...) ⇒ Array #attr_writer(string, ...) ⇒ Array

Creates an accessor method to allow assignment to the attribute symbol.id2name. String arguments are converted to symbols. Returns an array of defined method names as symbols.

Overloads:

  • #attr_writer(symbol, ...) ⇒ Array

    Returns:

  • #attr_writer(string, ...) ⇒ Array

    Returns:



2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
# File 'object.c', line 2373

static VALUE
rb_mod_attr_writer(int argc, VALUE *argv, VALUE klass)
{
    int i;
    VALUE names = rb_ary_new2(argc);

    for (i=0; i<argc; i++) {
        ID id = id_for_attr(klass, argv[i]);
        rb_attr(klass, id, FALSE, TRUE, TRUE);
        rb_ary_push(names, ID2SYM(rb_id_attrset(id)));
    }
    return names;
}