Comments (5)
Is this not covered by stdlib withDefault
?
from arrow.
Is this not covered by stdlib
withDefault
?
Didn't know about that method! π
That's neat and covers almost everything. There's one neat feature of having it in a wrapping class though, and that's that you can override the get
method to return V
instead of V?
, and avoid either banging or null coalescing an output that you already know is not null.
It does make the concept a lot less useful though, as it covers most of the use-cases (and the use-case I mentioned in particular).
from arrow.
get
being nullable by default is annoying. getValue
exists, but sometimes I wish it'd be the default, with a getOrNull
function instead. Maybe we can do something here, but it would be sort of strange to redefine all of this in Arrow just to get better typing for that one method.
This could be a good stdlib request to expose their MapWithDefault
interface
from arrow.
I agree with @kyay10, this is already partially covered by Kotlin Std, and I don't think it really belongs in Arrow. Regardless of that I think MapWithDefault
would be beneficial.
Beware that get
doesn't actually return the value defined by withDefault { }
AFAIK, and it requires using getValue
. At least this used to be the case, not sure if this has been fixed yet.
This is because get
is defined on Map
, and doesn't use the Java's get
and thus ignore the withDefault { }
handler.
from arrow.
I'm going to close the issue for now, but feel free to re-open or discuss further
from arrow.
Related Issues (20)
- arrow-stack does not specify version of "io.arrow-kt:arrow-optics-ksp-plugin" HOT 2
- Retrofit+Arrow to Ktor Client+Arrow migration HOT 8
- Road to 1.2.3 HOT 7
- @optics generates bad code for sealed hierarchies with changing property nullability
- @optics generates bad code when dealing with generic properties in a sealed hierarchy
- @optics generates bad code when dealing with nested generic sealed hierarchies
- ["Documentation"] Ior Knit examples not rendering properly
- autoCloseScope: the order of close method calls is not the same as `AutoCloseable.use` HOT 2
- Tracing reports a swallowed CancellationException warning HOT 7
- Fold restriction not allowing any Function<*> to be returned is too strict HOT 20
- ["Request"] Raise DSL for working with nonEmptyLists HOT 3
- @optics generates bad code for data class with generic named 'S'
- ["Bug"] Arrow core 1.2.4 not compatible with Kotlin WASM JS HOT 3
- ["Request"] Annotate Raise interface with @RaiseDSL HOT 2
- Discussion around the Gradle setup HOT 1
- ["Request"] Resilience Saga allow
- ["Request"] mention `result` computation block API in learning docs
- Update Arrow 2.0.0-alpha.2 misses a dependency HOT 2
- ["BUG"] Arrow Optics, `it` package in lambda
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arrow.