Ellen Spertus
09/28/2024, 8:07 PM!!
is of course. Is ??
a thing, or is my strategy of learning programming languages from r/ProgrammerHumor misguided?Shawn
09/28/2024, 8:18 PMis my strategy of learning programming languages from r/ProgrammerHumor misguided?lmao
Shawn
09/28/2024, 8:19 PM??
isn't really a thing in Kotlin I don't think? like T??
is syntactically valid but resolves to T?
so ¯\_(ツ)_/¯Shawn
09/28/2024, 8:20 PM??
is sometimes the null-coalescing operator in other languages (Swift and C# come to mind), but we use ?:
for that so I'm not sure what they meanEllen Spertus
09/28/2024, 8:23 PMEllen Spertus
09/28/2024, 8:23 PMShawn
09/28/2024, 8:24 PM!!
is the least of your worries—platform types, inheritance, and improper passing of this
in an init
block or similar usage are all much more likely to cause Kotlin NPEsEllen Spertus
09/28/2024, 8:29 PMShawn
09/28/2024, 8:29 PMShawn
09/28/2024, 8:30 PMShawn
09/28/2024, 8:30 PMkotlinc
doesn't have robust enough validation around that unfortunatelyEllen Spertus
09/28/2024, 8:32 PMShawn
09/28/2024, 8:32 PMShawn
09/28/2024, 8:35 PMShawn
09/28/2024, 8:36 PMEllen Spertus
09/28/2024, 8:37 PMShawn
09/28/2024, 8:37 PMEllen Spertus
09/28/2024, 8:39 PMYoussef Shoaib [MOD]
09/29/2024, 9:59 AMSomeType?
In Kotlin is that it's very similar to an Option<SomeType>
in other languages. Null dereferencing has to be explicit, we just use !!
For that, while other languages have other constructs (e.g. I think Rust uses unwrap
or something like that). Kotlin absolutely offers null-safety, but it can't easily prevent you from accessing potentially uninitialized data. The fact that uninitialized data happens to be represented by null
is practically implementation detail.Stephan Schröder
09/29/2024, 2:44 PMAndy Dent
09/29/2024, 3:41 PMEllen Spertus
09/29/2024, 7:05 PMEllen Spertus
09/29/2024, 7:08 PMSummary: "Null and Nullability" is a satirical romance set in the fictional town of Bitshire. The story follows the clever and spirited Miss Ada Lovelace, a young woman with an uncommon passion for mathematics and logic. When the mysterious and wealthy Mr. Charles Babbage arrives in town, Ada finds herself torn between her growing affection for him and her desire to prove her worth in a field dominated by men. As she navigates the complex social algorithms of Regency-era England, Ada must determine whether her heart is truly nullable or if Mr. Babbage might be the one to assign it a value.
Excerpt: It is a truth universally acknowledged that a single man in possession of a good fortune must be in want of a wife. However, the wishes of such a man upon entering a neighbourhood are seldom considered by those eager to see him wed.
Miss Ada Lovelace stood by the window of her father's study, her fingers idly tracing the outline of a complex equation etched into the glass. The rumours of Mr. Charles Babbage's arrival in Bitshire had set the town atwitter, but Ada found herself more intrigued by the whispers of his revolutionary calculating machine than by speculation about his yearly income.
"My dear Ada," her mother's voice rang out as she entered the room, "you cannot mean to greet our new neighbour in such a state! Your hair is positively null, and your dress is in dire need of initialization."
Ada sighed, turning from her contemplation of prime numbers to face her mother's scrutiny. "Mama, I assure you, my appearance is perfectly adequate for any rational being. Besides, I doubt Mr. Babbage will be evaluating my suitability based on the state of my coiffure."
Mrs. Lovelace tutted disapprovingly. "Oh, you impossible girl! When will you learn that a young lady's prospects are not determined by the capacity of her mind, but by the charm of her manner and the elegance of her attire?"
"Perhaps," Ada replied with a wry smile, "when the gentlemen of our acquaintance learn to value a woman for more than her ability to pour tea and recite sonnets. Until then, I shall continue to cultivate my intellect, even if it renders me null and void in the eyes of society."
As her mother launched into another lecture on the importance of securing a suitable match, Ada's thoughts drifted back to the fascinating rumours of Mr. Babbage's invention. Little did she know that their impending meeting would set in motion a series of events that would challenge everything she thought she knew about logic, love, and the nullability of the heart.
okarm
09/30/2024, 12:28 PMval
an "immutable variable" which some people still keep saying after all these years. It is just a "read-only property" - i.e. the reference cannot be reassigned. Which says nothing about the mutability of the referenced object.
Terminology is important.Klitos Kyriacou
10/07/2024, 3:21 PMconst var
, the self-contradictory "constant variable".