Skip to content

Instantly share code, notes, and snippets.

@heatherjc07
Last active December 15, 2015 13:28
Show Gist options
  • Select an option

  • Save heatherjc07/5267160 to your computer and use it in GitHub Desktop.

Select an option

Save heatherjc07/5267160 to your computer and use it in GitHub Desktop.
Baby := Object clone
Baby description := "A little person"
Baby cry := method("Wahh" println)
Baby slotNames println
// Returns list(cry, description, type)
Baby cry
// Returns "Wahh"
Vehicle description := "Takes you from A to B"
Vehicle description
//Returns "Takes you from A to B"
::= //Creates slot, creates setter, assigns value
:= //Creates slot, assigns value
= //Assigns value to slot if it exists, otherwise raises exception
ferrari getSlot("drive")
// Returns method ("Vroom" println)
pets := list("dog", "cat") // returns list("dog", "cat")
pets size // returns 2
pets append("rabbit") //returns list("dog", "cat", "rabbit")
list(1, 2, 3, 4)
list(1, 2, 3, 4) average //returns 2.5
list(1, 2, 3, 4) sum //returns 10
list(1, 2, 3) pop // returns 3
horse := Map clone
horse atPut("home", "stable")
horse at("home") //returns home = "stable"
horse atPut("food", "hay") //returns food = "hay"
horse asList //returns list(list("food", "hay"), list("home", "stable"))
horse keys //returns list("food", "home")
horse size //returns 2
Car drive := method("Vroom" println)
ferrari := Car clone
ferrari drive
//Returns Vroom
io answer.io
Madonna := Object clone
Madonna clone := Madonna
Vehicle := Object clone
Vehicle description := "Something to take you places"
Vehicle slotNames println
Vehicle slotNames
//Returns ("type", "description")
(1 + 1) println // 2
//1 + "one" println
// Exception: argument 0 to method '+' must be a Number,
// not a 'Sequence'
//Therefore Strongly Typed
Vehicle := Object clone
if(0) println // true
if("") println //true
if(nil) println //false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment