Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [nullability]

The tag has no usage guidance.

nullability
0 votes
0 answers
33 views

Issue with nullability specifiers in Xcode when developing Flutter app

I'm developing a Flutter application and encountering an issue with nullability specifiers in Xcode. Specifically, I have methods in my Objective-C files where Xcode is reporting conflicts with ...
Whirley Paul's user avatar
1 vote
1 answer
115 views

How to avoid the "type test cannot be checked" waring in pattern matches of nullable types?

The intention of the following method is to remove null values def filterOutNulls[T](items: Iterable[T | Null]): Iterable[T] = items.collect { case element: T => element } The code works at ...
Readren's user avatar
  • 1,216
0 votes
1 answer
71 views

How to get unknown nullability function return type in Kotlin?

What I want to achieve is to get Any! return type from function, so I can determine myself whether to handle nullability or not. The only way to get this type I found is to call a Java function. For ...
Сергей Андриенко's user avatar
3 votes
1 answer
115 views

how to force that a generic method never returns a null value

In the following example: async Task Main() { // data can actually NEVER be null, but here it is of type Response? var data1 = GetResponseData(); var data2 = await GetResponseDataAsync(); }...
fpdave100's user avatar
-2 votes
1 answer
41 views

Kotlin - Issue with Elvis operator

Why the below code gives error? It should print "Bonjour" as output fun main() { var a:String? = null var b:String? = "Hello" var result1 = a?:"Gracias" ...
Raghul G's user avatar
2 votes
4 answers
342 views

Is it possible to create a String extension `isEmptyOrNull` in dart?

First off let's define some criteria for this extension: It should return true if the object is null or an empty string. I should be able to use it on a chained nullable object. I should not have to ...
Joel Broström's user avatar
0 votes
1 answer
66 views

Filtering for Non-Nullable Strings in C# Lists

I'm trying to create a list of non-nullable string values by filtering, but I always end up with a list of nullable strings. var list = new List<string?> {"Cars", "Audi", &...
group's user avatar
  • 9
1 vote
1 answer
81 views

Nullability Check: Difference between literals and objects, or: "Why does "if(is null) [..]" work for object? but not for int?/long?/.. ?"

I stumbled across an interesting issue where I do not have any explanation for, hoping someone could explain. When dealing with nullable objects (pseudo) code like the following works (Note: working ...
user3227340's user avatar
-1 votes
1 answer
110 views

Vector of 'nullable' HashMaps in rust

I am finding extremely difficult to deal with vectors of HashMaps in rust. I want to use vectors of HashMaps as an implementation of a sparse matrix container according to constraints that I, ...
Redirectk's user avatar
  • 202
1 vote
0 answers
224 views

Nullability of generic type arguments

So far I've worked with Nullable.GetUnderlyingType and even NullabilityInfo.WriteState to determine the nullability of types. This worked well - sometimes. I'd like to know the nullability of the ...
nd_'s user avatar
  • 131
2 votes
1 answer
149 views

Making the C# compiler aware that a null-oblivious method may return null?

AutoMapper's T IMapper.Map<T>(object) is null-oblivious for historical reasons. If you pass null, the result is null. The C# compiler does not warn about the possible null return when returning ...
Kevin Krumwiede's user avatar
0 votes
1 answer
394 views

Stop nullability warnings from entity framework queries that include nullable navigation properties

Consider an entity framework core model with the following two entities: public class RiskAssessment { public string Title { get; set; } = string.Empty; public Guid? ActivityID { get; set; } ...
Kevin O'Donovan's user avatar
0 votes
2 answers
573 views

What is the difference between LiveData<String>() and LiveData<String?>()

I am new to LiveData thing in general and I am having a hard time understanding the difference between LiveData<String>() and LiveData<String?>(). I used them interchangeably and nothing ...
Khalida Aliyeva's user avatar
0 votes
1 answer
42 views

Is there a way to indicate to C# nullability analysis that an instance variable will never be null after a certain method runs?

I've got a class with an instance var that can be null, and that class has a method that initializes that var. Broadly simplified, it looks a bit like this #nullable enable class SomeClass { ...
newclearwinter's user avatar
0 votes
1 answer
316 views

Make the Intellisense nullability warning conditional, similar to Dictionary<string, string>.TryGetValue(...)

In Visual Studio, Intellisense is smart enough to know that the 'out' variable value in Dictionary<string, string>.TryGetValue(string key, out string value) is not null if the method returns ...
user3163495's user avatar
  • 3,295

15 30 50 per page