Sha256: 4017bcb114ab8b948226377e492b1c8141416a1234bcd6a35594cb6b3f79bf10

Contents?: true

Size: 588 Bytes

Versions: 2

Compression:

Stored size: 588 Bytes

Contents

A Struct is a convenient way to bundle a number of
attributes together, using accessor methods, without
having to write an explicit class. The Struct class
is a generator of specific classes, each one of which
is defined to hold a set of variables and their
accessors. While Modules house behaviors in instance
methods, Structs house mainly behaviors in variables
and accessors.

Examples:
Customer = Struct.new(:name, :address, :zip)
joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
joe.name     #=> Joe Smith
joe.address  #=> 123 Maple, Anytown NC
joe.zip      #=> 12345

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubytutor-0.1.1 lib/descriptions/Struct.txt
rubytutor-0.1.0 lib/descriptions/Struct.txt