jamiebuilds / ghost-lang

:ghost: A friendly little language for you and me.
302 stars 10 forks source link

What are records? #29

Closed itsdarrylnorris closed 5 years ago

itsdarrylnorris commented 5 years ago

It's unclear to me when and how to use records?

Records

let three = :three

let record = {
  one: 1,
  two: 2,
  [three]: 3,
}

let one = record.one
let two = record[:two]
let three = record[three]

let newRecord = {
  one: 'default',
  ...record,
  three: 'new value',
}

How do records work?

jamiebuilds commented 5 years ago

Think of them as super lightweight objects, where all the keys are symbols instead of strings or something