|
|
|
|
|
by mitt_romney_12
751 days ago
|
|
But now every function that reads from stdin needs to pass around an offset of where to read from which is very unergonomical. It also isn't really pure since offset is now state that is changing whenever a function is called. fn do_stuff(offset: int) -> (string, int) {
x = read_guess(offset)
y = read_name("what's your name: ", offset + len(x))
z = read_guess(offset+len(x)+len(y))
new_offset = offset+len(x)+len(y)+len(z)
return ("name is: {y}, guess is: {x}", new_offset)
} |
|