You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not exactly sure what you're asking, but I'll assume that you want to know how to skip only a single step instead of skipping all the following steps as Failure does. If that's you're question, then I'd suggest doing something like:
require'deterministic'classFooincludeDeterministic::Preludedefcall(id: nil)result=in_sequencedoget(:id){get_id(id)}get(:ctx){get_ctx(id)}and_yield{format_response(ctx)}endenddefget_id(id)Success(id)enddefget_ctx(id)ifid == 10in_sequencedoget(:ctx){Success(id + 1)}and_yield{Success(ctx + 2)}# or id + 2 as you have itendelseSuccess(1)endenddefformat_response(id)Success("Your id is #{id}")endendFoo.new.call(id: 10)
That is, you can't use Failure, because that will abort the entire chain. You can use standard Ruby if/else, however, and nest Result chains within each other.
Hi. I have a question about in_sequence!.
My question is how i can skip one step in sequence, in this simple example i want skip the step:
and return me 11, there is one way to integrate Pattern matching and where with in_sequence
Thanks, and congratulation for your gem.
The text was updated successfully, but these errors were encountered: