What's the expected behaviour here? ```either { ...
# arrow-contributors
y
What's the expected behaviour here?
Copy code
either {
  accumulate {
    ensureOrAccumulate(false) { "hello" }
    this@either.raise("hi".nel())
  }
}
This results in
nonEmptyListOf("hi").left()
, but I can see an argument for it being
nonEmptyListOf("hi").left()
. It gets even more strange with early returns:
Copy code
either {
  accumulate {
    ensureOrAccumulate(false) { "hello" }
    return@either 42
  }
}
Results in
Right(42)
, but the very similar:
Copy code
either {
  accumulate {
    ensureOrAccumulate(false) { "hello" }
    42
  }
}
results in
nonEmptyListOf("hello").left()
Is this expected? Should the accumulated errors be raised instead?
a
the expected behavior is that if you "reach out" to the outer
Raise
, the behavior depends completely on that one
either using
this@either.raise
or
return@either
y
Okay, just verifying! The behaviour is consistent, it's just a little strange when compared to the normal-return case