Skip to content

Instantly share code, notes, and snippets.

@drinkmorewaters
Created April 29, 2020 04:22
Show Gist options
  • Save drinkmorewaters/22df73406e9eb5c83d73aeaeba7a5331 to your computer and use it in GitHub Desktop.
Save drinkmorewaters/22df73406e9eb5c83d73aeaeba7a5331 to your computer and use it in GitHub Desktop.
Create Struct in Crystal
struct Cars
getter price : Int64
getter condition : String
def initialize(@type : String, @price : Int64, @condition : String, @location : String, @color : String)end
end
johns_car = Cars.new "Holden", 10000, "Fair", "New York", "Red"
puts "Johns car is in #{johns_car.condition} condition, although, the price is cheap at only #{johns_car.price}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment