Skip to content

End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

Module#attr_reader

attr_reader(symbol, ...) → array
attr(symbol, ...) → array
attr_reader(string, ...) → array
attr(string, ...) → array

Creates instance variables and corresponding methods that return the value of each instance variable. Equivalent to calling “attr:name” on each name in turn. String arguments are converted to symbols. Returns an array of defined method names as symbols.

Ruby version changes

  1. 3.0
See also #attr_accessor #attr_writer #attr #autoload also in 4.1 · 4.0 · 3.4 · 3.3 · 3.1 · 3.0