Why i would need to use "Null"? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why i would need to use "Null"?

can u post a simple real code in which u used "Null" and explain to me how does it work in the code and why u used it ?

12th Jan 2017, 6:59 PM
Mohamed Ammar
Mohamed Ammar - avatar
6 Answers
+ 6
Null just means nothing. In a real-world context, null can be useful when you want to test if something is empty or not-defined. For example, if I want to search a user from the list, I could use "null" in the if-else statement first to ascertain that the list exists in the first place.
12th Jan 2017, 7:24 PM
Wen Qin
Wen Qin - avatar
+ 4
placeholder for most data types or unsetting an object, like killing a pdo connection
12th Jan 2017, 7:05 PM
Louis Milotte
Louis Milotte - avatar
+ 3
Why we would need to use "Zero" ( 0 )? Zero is useful for saying 'nothing' when we know the quantity/number is really zero. But it can be also useful to have another value, which could say that we don't know the count: zero, in this case, isn't really the same. So, a value as 'Null' allows to assign to variables a non-value ^^
12th Jan 2017, 7:25 PM
visph
visph - avatar
+ 2
is this question related to a specific language, or any language in general?
12th Jan 2017, 7:05 PM
ifl
ifl - avatar
0
C#
12th Jan 2017, 7:46 PM
Mohamed Ammar
Mohamed Ammar - avatar
0
thanks for ur answers, all of u really helped me understanding "Null"
12th Jan 2017, 7:48 PM
Mohamed Ammar
Mohamed Ammar - avatar