Derw
  • Derw
  • Roadmap
  • 📖Guides
    • Creating your first project
    • Installing packages
    • Compiling and running your code
    • Formatting
    • Repl and playground
    • Testing
  • ⚖️Fundamentals
    • Literals
    • Definitions
    • Types
    • Conditionals
    • Imports and exports
    • Comments
  • 🔧Building things
    • Web pages
    • REPLs
  • 🪛Contributing
    • Contribution flow
    • Working on the compiler
  • 💭Hypotheticals
    • Hypotheticals
    • Async / await
Powered by GitBook
On this page
  • Strings
  • Numbers
  • Booleans
  • Null
  • Lists
  • List ranges
  • Objects
  • Spread operator
  1. Fundamentals

Literals

Strings

Regular strings can be denoted through double quotation marks. String interpolation can be done through backticks.

"hello world"
`hello ${name}`

Numbers

10
-10

Booleans

true
false

Null

null

Lists

[ 1, 2, 3, 4 ]

List ranges

[ 1..10 ] -- produces [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
[ n..m ]

Objects

{ name: "Noah", age: 29 }

Spread operator

In order to update an existing object, you can use the ... spread operator. This will create a new version of the object, which you can then modify fields on. For example:

type alias Person = {
    age: number,
    name: string
}

person: Person
person = { age: 27, name: "Noah" }

olderPerson: Person
olderPerson = { ...person, age: 79 } -- equal to { age: 79, name: "Noah" }
PreviousTestingNextDefinitions

Last updated 2 years ago

⚖️