Comments (6)
I see one issue:
If we get a value from outside of kotlin, for example, String!
, this thing would allow to be passed to Some. In that case, we would have some with possible null
from kotlin-options.
True. The question then becomes, if we can't trust the calling code to use T!
appropriately (that is; treat it as T?
), could we trust them to use optionOf
if that was the only creator method available?
from kotlin-options.
If the Some
constructor is exposed, only the initial creation will be unsafe for T!
- Kotlin fails fast if you attempt to use a null
value for T : Any
.
from kotlin-options.
The reason why I like optionOf
being the only way to create Some
is that we are sure that it will never have inconsistent state. And people will be using those options mainly with stuff that comes from the system (T!
)
from kotlin-options.
With the current: internal constructor
we can still use Some("abc")
, so we aren't forced to use optionOf
for tests (at least in OptionTest
)
from kotlin-options.
I'm going to leave it out of the API, but update OptionTest
to use it.
from kotlin-options.
Related Issues (7)
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 kotlin-options.