Java 8 resolved the Tri-lean case, and I didn't know !
-
@jaloopa There's more info about this on the team's GitHub.
https://github.com/dotnet/csharplang/blob/master/proposals/nullable-reference-types.md
-
@raceprouk hmmm
I can't really see this getting past the -100 points barrier, although I would probably start using it in new development if it were added.
Seems like a huge amount of changes to satisfy it in any legacy codebase though
-
@powerlord said in Java 8 resolved the Tri-lean case, and I didn't know !:
Not in C#.
Ben said:
@ben_lubar said in Java 8 resolved the Tri-lean case, and I didn't know !:
(That's
Nullable<String>
for you Java people).which has the common meaning that he was translating the concept into Java terms. For Java people,
Nullable<String>
is nonsensical.
-
I think this should be implemented in both Java and C#:
-
Brilliant onebox there
-
-
@greybeard I took it as an explanation of what
string?
(or more accurately, the?
) means, which the compiler converts intoNullable<String>
.And also, for Java people,
string
(all lowercase) is converted into theSystem.String
class.
-
@wharrgarbl Kotlin does the ? thing. That's likely to be where Java folk go for that sort of thing.
-
@greybeard said in Java 8 resolved the Tri-lean case, and I didn't know !:
An Optional can either be empty or contain a non-null value. Having the Optional itself be null is .
No, having an
Optional
that can benull
orempty
is . This kind of abstraction just makes no sense as reference type.
-
@bulb said in Java 8 resolved the Tri-lean case, and I didn't know !:
No, having an Optional that can be null or empty is .
Are you saying Optionals must have a mandatory value?
-
@bulb said in Java 8 resolved the Tri-lean case, and I didn't know !:
No, having an Optional that can be null or empty is .
Please, re-read what you wrote, especially the highlighted part.
-
Yeah, the possibility of being empty is what makes it, as it were, optional.
In the Java language, a variable of reference type can hold a null reference. The reference type has no way to prohibit that. Perhaps some day they'll extend the language to permit declaring a variable such that it cannot be assigned a null reference.
Or people will switch to Kotlin, which fixes some time-consuming annoyances and gratuitously renames some basic types.
-
This post is deleted!
-
-
@greybeard said in Java 8 resolved the Tri-lean case, and I didn't know !:
Perhaps some day they'll extend the language to permit declaring a variable such that it cannot be assigned a null reference.
I've seen that done with a minor extension. By putting a
@Nonnull
attribute on the variable, you prohibit the variable from holding a null. You can put that on fields, local variables, arguments and return values (well, on methods, but that means the return value) and it pretty much checks all those assumptions you've got. Useful. Or would be if it was a standard part of Java and the standard library was annotated with them. Without that, it's mostly painful.
-
@sloosecannon said in Java 8 resolved the Tri-lean case, and I didn't know !:
I saw that @dkf.
Yeah. Totally misread what @Greybeard was saying. Deleted and started over.
-
@dkf said in Java 8 resolved the Tri-lean case, and I didn't know !:
@sloosecannon said in Java 8 resolved the Tri-lean case, and I didn't know !:
I saw that @dkf.
Yeah. Totally misread what @Greybeard was saying. Deleted and started over.
:) Figured. I was gonna respond and say "Uh, wut" :P
-
@sloosecannon said in Java 8 resolved the Tri-lean case, and I didn't know !:
@dkf said in Java 8 resolved the Tri-lean case, and I didn't know !:
@sloosecannon said in Java 8 resolved the Tri-lean case, and I didn't know !:
I saw that @dkf.
Yeah. Totally misread what @Greybeard was saying. Deleted and started over.
:) Figured. I was gonna respond and say "Uh, wut" :P
I'm currently operating in no-caffeine state. Alas, this hotel's idea of fixing that is… instant coffee…
-
@dkf said in Java 8 resolved the Tri-lean case, and I didn't know !:
@sloosecannon said in Java 8 resolved the Tri-lean case, and I didn't know !:
@dkf said in Java 8 resolved the Tri-lean case, and I didn't know !:
@sloosecannon said in Java 8 resolved the Tri-lean case, and I didn't know !:
I saw that @dkf.
Yeah. Totally misread what @Greybeard was saying. Deleted and started over.
:) Figured. I was gonna respond and say "Uh, wut" :P
I'm currently operating in no-caffeine state. Alas, this hotel's idea of fixing that is… instant coffee…
Ouch...
-
-
@greybeard said in Java 8 resolved the Tri-lean case, and I didn't know !:
@dkf said in Java 8 resolved the Tri-lean case, and I didn't know !:
no-caffeine state
Utah?
Ahah. I see what you did there.
-
@raceprouk said in Java 8 resolved the Tri-lean case, and I didn't know !:
@ben_lubar said in Java 8 resolved the Tri-lean case, and I didn't know !:
@greybeard I wish C# strings weren't nullable, so I could do
string? foo;
(That'sNullable<String>
for you Java people).That's a proposed feature for C# 8.
What? 7.1 hasn't been released yet and there are already proposed features for 8? These guys are fast and furious. Way to go, Mads!