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 sometimes want to modify the first or last element of a NonEmpty collection. Afaik Swift.MutableCollection doesn't allow this because of the optionality (semantics of setting nil would be unclear). However, NonEmpty doesn't have this problem.
Im currently using the below proxy, which achieves someNonEmptyCollection.mutable.last = ... syntax.
However, I think it should be pretty easy to add a setter directly to first and last properties to achieve someNonEmptyCollection.last = ... syntax. I personally don't see many downsides, but I feel like you might shut this down on the grounds of deviating from Swift standard library. So I wanted to get a quick 👍 or 👎 before I start working on a PR.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hey pointfreeguys,
I sometimes want to modify the
first
orlast
element of aNonEmpty
collection. AfaikSwift.MutableCollection
doesn't allow this because of the optionality (semantics of settingnil
would be unclear). However,NonEmpty
doesn't have this problem.Im currently using the below proxy, which achieves
someNonEmptyCollection.mutable.last = ...
syntax.However, I think it should be pretty easy to add a setter directly to
first
andlast
properties to achievesomeNonEmptyCollection.last = ...
syntax. I personally don't see many downsides, but I feel like you might shut this down on the grounds of deviating from Swift standard library. So I wanted to get a quick👍
or👎
before I start working on a PR.Thanks!
Beta Was this translation helpful? Give feedback.
All reactions