Discord is now Scala’s main chat platform. Please join us at https://discord.com/invite/scala
run
, will take the input state, return it as the output, and leave it unmodified for the next state
will take the input state, return it as the output, and leave it unmodified for the next state
that's the English description of what it does, you need to see that same description in the code
get[Int].run(3)._1 == 3
just a second before we go further...
sure
State[S, A]
, A
is the output
get: State[Int, Int]
State[Int, Int]
(the first Int
is the state, and stays as it is, the second state is the result, and gets incremented)State[Int, String]
(the state is an Int, the result is now String
)