From: Julian Leviston Date: 2013-04-11T23:12:58+09:00 Subject: Re: confusion with Struct class On 11/04/2013, at 11:59 PM, Love U Ruby wrote: > Thanks @Matthew and @Jesús. > > Customer = Struct.new(:name, :address) > > and > > Struct.new("Customer", :name, :address) > > > Is both the declaration will work same way? Means any more differences > with the above two approaches? > > Thanks > > -- > Posted via http://www.ruby-forum.com/. Customer = Struct.new(:name, :address) You'll have to use Customer.new to create new customers, but in: Struct.new("Customer", :name, :address) It'll register the Customer class inside the Struct class, so you'll have to refer to it like this: Struct::Customer.new Struct is a class that GENERATES other classes for you. The syntax where you pass in the name of the class registers the new class inside the struct class... the other syntax doesn't, it just registers it against whatever you assign it to. Point in case: >> x = Struct.new(:name, :address) => # >> x.new => # Julian