Questions tagged [null]
This tag should be used for questions where you are handling null variables or values.
160
questions
0
votes
3
answers
92
views
Calculate length of continuous gaps
So, I have a list with some nan values, out of which some are continuous. e.g, list = [1, 2, 3, np.nan, np.nan, 6, 7, np.nan, 9, np.nan,np.nan,np.nan, 12] For some necessary reason, I'd want to get ...
10
votes
3
answers
5k
views
Filter out nulls from sequence of nullables to produce sequence of non-nullables
While introducing nullable reference types to our enterprise application's codebase, I found that we are often using LINQ on sequences of nullable reference types where we filter out the nulls using <...
3
votes
1
answer
1k
views
Setting all class members to null to destroy strong references
At work we are using Xamarin.iOS for our apps. We frequently have to fight it's disadvantages, namely it's memory leak issues where strong cyclic references keep objects alive and prevent them from ...
0
votes
1
answer
75
views
Android APP User class implementation
This is a follow-up question for Android app class serialization. The implementation of User class has been updated and the functionality of null string checking, ...
1
vote
1
answer
141
views
Conventional C# for LinkedList with (non-)nullable references + xunit tests
I'm new to C# and would appreciate any feedback you might have on the following doubly-linked list implementation, particularly WRT the following language features:
Exception handling
Debug.Assert
...
9
votes
3
answers
3k
views
Error solution: Uncaught TypeError
Uncaught TypeError: document.getElementById(...) is null
I have a single JavaScript file that is connected to multiple pages. The below snippet is a function that is used for a single page. The above ...
14
votes
6
answers
3k
views
C# consecutive and redundant null checks
I am working on a C# application and I want to support multiple themes, so I wrote a ThemeManager class that can check, load and apply a specific theme. A theme is ...
2
votes
0
answers
343
views
Extension method: Task<T>.CoalesceAwait
There has been ongoing concern about the question of awaiting a task that could possibly be null, as when using null-coalescing operators. Consider the following:
...
3
votes
1
answer
105
views
Non-nullable reference type default parameters in C# 8
I was working to upgrade some code to C# 8.0 and came across an interesting pattern with default parameters and non-nullable reference types. I'm working if it's clear enough to the caller.
Given ...
-2
votes
1
answer
104
views
How to get rid of many if null checks - c# [closed]
How could I refactor this code to get it more cleaner:
...
6
votes
5
answers
362
views
Simplify & Reduce steps in the IsDistinct function
Because I often have to deal with two Variants that may or may not be Null, we need a null-safe equality test, so I came up with ...
6
votes
2
answers
21k
views
handle null in Comparator class
I have a class LoanAccount that contains an attributes creationDate and loanAmount.
I ...
2
votes
3
answers
1k
views
String whitespaces
Here is a shortest possible syntax for replacing whitespaces with null and throwing an exception where it is not allowed:
...
5
votes
2
answers
789
views
Multiple null Checks or try/catch NullPointerException [closed]
There is A LOT of information online stating that you should NEVER catch a NullPointerException. Generally I agree, but I am wondering about this one case.
I have inherited code that requires me to ...
6
votes
4
answers
3k
views
Handling Null values (and equivalents) routinely in Python
I've found the following code invaluable in helping me 'handle' None values including "whitespace" characters that should be treated as None based on the situation. I have been using this code for ...