Would you return a `Sequence` from a public method...
# codereview
m
Would you return a
Sequence
from a public method? I normally use Sequence to optimise collection operations, and return the end result as a list or so. However, now I have a scenario in which I want to return a collection but half of the operations may change depending on the scenario. I could early terminate (return to a list) and sacrifice performance (as more operations will be required) or return the
Sequence
. What do you think? 🤔
p
Sure, why not? I would recommend documenting clearly if it’s a re-usable sequence or if it can only be traversed once, for instance, but there’s no reason not to return it as long as you’re clear about what it is you’re returning