Why doesn’t C have a ||= operator, or any other language for that matter? Is there some technical reason, or is it for language aesthetics?
Edit Apparently Perl and Ruby have this, I didn’t know that when asking.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In C this operator would be utterly nonsense. Think about the following example:
This is doing exactly what
||=would achieve. For all types that are non-castable to bool this would be stupid anyways. Am I missing something?In all other programming languages without type inference this operator would only be valid for booleans.