tresure-chest
This commit is contained in:
21
treasure-chest/src/treasure_chest.gleam
Normal file
21
treasure-chest/src/treasure_chest.gleam
Normal file
@@ -0,0 +1,21 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user