Lists and Pipelines
Lists use square brackets.
let names = ["Nikolas", "Donna"]
let numbers = [1, 2, 3]
List patterns can pull out the head and tail.
fn first_or_default(items: List(String)) -> String:
case items:
[] -> "none"
[head, .._] -> head
The pipe operator sends a value into the next function call.
import donna/string
fn join_greetings(names: List(String)) -> String:
string.join(names, ", ")
pub fn main() -> Nil:
["Nikolas", "Donna"]
|> join_greetings
|> echo
Use pipes when each step has a clear name. If the direct function call is easier to read, use that. Good taste wins.