blob: 2ba907a018de337667df9ba3d99389a1ad7f7167 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
import gleam/io
pub fn main() {
let a = unsafely_get_first_element([123])
io.debug(a)
let b = unsafely_get_first_element([])
io.debug(b)
}
pub fn unsafely_get_first_element(items: List(a)) -> a {
// This will panic if the list is empty.
// A regular `let` would not permit this partial pattern
let assert [first, ..] = items
first
}
|