/Ruby 2.7

class FrozenError


Raised when there is an attempt to modify a frozen object.

[1, 2, 3].freeze << 4

raises the exception:

FrozenError: can't modify frozen Array

Public Class Methods

new(msg=nil, receiver: nil) → frozen_error Show source
static VALUE
frozen_err_initialize(int argc, VALUE *argv, VALUE self)
    ID keywords[1];
    VALUE values[numberof(keywords)], options;

    argc = rb_scan_args(argc, argv, "*:", NULL, &options);
    keywords[0] = id_receiver;
    rb_get_kwargs(options, keywords, 0, numberof(values), values);
    rb_call_super(argc, argv);
    err_init_recv(self, values[0]);
    return self;

Construct a new FrozenError exception. If given the receiver parameter may subsequently be examined using the FrozenError#receiver method.

a = [].freeze
raise FrozenError.new("can't modify frozen array", receiver: a)

Public Instance Methods

receiver → object Show source
#define frozen_err_receiver name_err_receiver

Return the receiver associated with this FrozenError exception.

Ruby Core © 1993–2017 Yukihiro Matsumoto
Licensed under the Ruby License.
Ruby Standard Library © contributors
Licensed under their own licenses.