this post was submitted on 24 Nov 2025
20 points (100.0% liked)
Programming
23594 readers
119 users here now
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Rules
- Follow the programming.dev instance rules
- Keep content related to programming in some way
- If you're posting long videos try to add in some form of tldr for those who don't want to watch videos
Wormhole
Follow the wormhole through a path of communities !webdev@programming.dev
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
So you're using
[]as an alternative function call syntax to(), usable with nullable parameters?What's the alternative?
let x = n is null ? null : math.sqrt(n);?In principle, I like the idea. I wonder whether something with a question mark would make more sense, because I'm used to alternative null handling with question marks (C#,
??,?.ToString(), etc). And I would want to see it in practice before coming to an early conclusion on whether to establish as a project principle or not.math.sqrt?()may imply the function itself may be null.(? )formath.sqrt(?n)? ๐คI find
[]problematic because it's an index accessor. So it may be ambiguous between prop or field indexed access and method optional param calls. Dunno how that is in Dart specifically.Yeah pretty much as you said. I tried overriding
?[]to make it more clear but apparently?operators can't be overriden.I think I'll go for
.callMaybe()