22 lines
371 B
Gleam
22 lines
371 B
Gleam
pub type TreasureChest(a) {
|
|
TreasureChest(String, a)
|
|
}
|
|
|
|
pub type UnlockResult(a) {
|
|
Unlocked(a)
|
|
WrongPassword
|
|
}
|
|
|
|
pub fn get_treasure(
|
|
chest: TreasureChest(treasure),
|
|
password: String,
|
|
) -> UnlockResult(treasure) {
|
|
case chest {
|
|
TreasureChest(pass, a) ->
|
|
case pass == password {
|
|
False -> WrongPassword
|
|
True -> Unlocked(a)
|
|
}
|
|
}
|
|
}
|