Hack hack hack...

An open journal-- some of it written for you, but most of it is for me.

Struct

Struct
1
2
3
4
5
Struct.new("Flatiron", :name, :location)

flatiron = Struct::Flatiron.new
flatiron.name "Flatiron"
flatiron.location = "33 West 26th st"
Here is another way to do it…
1
2
School = Struct.new(:name, :location)
flatiron = School.new("flatiron", "33 west 26th")
we can also define a method in the struct
1
2
3
4
5
6
7
8
9
School = Struct.new(:name, :location)
  def travel
      puts "going to #{location} location..."
  end
end

flatiron = School.new("flatiron", "33 west 26th")

flatiron.travel

Comments