18 lines
332 B
Text
18 lines
332 B
Text
package main
|
|
|
|
import strconv
|
|
import os
|
|
|
|
fun parse(value: String): Result<Int, Error> {
|
|
return strconv.atoi(value)
|
|
}
|
|
|
|
fun changeDirectory(path: String): Result<Unit, Error> {
|
|
return os.chdir(path)
|
|
}
|
|
|
|
fun main() {
|
|
println(parse("42").unwrap())
|
|
println(parse("invalid").unwrapOr(0))
|
|
changeDirectory(".").unwrap()
|
|
}
|