Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
inaba46315yYou're abusing the ternarys and it makes them sad :<<
You're not supposed to do assignment inside of the ternarys expression. The assignment is supposed to be the result of it -
What ur trying to do is:
return singleton != null ? null : new StaticFun();
You cannot assign inside an inline statement. -
@irene I'm supposed to return an instance on the first call and null after that. I know it makes no sense, don't ask me
-
@creskendoll Why though? Assignment is a normal operator and evaluates to the right hand value. That's how 'a = b = 1;' works
-
@creskendoll What I'm trying to do is what the code says. My problem is the weird ass syntax error for no reason
-
Whatever requirements that made this code necessary might be the most retarded thing I’ve seen. Beautiful solution. Not huge on java but would getter that sets value to null before get returns work? Then you might be able to avoid Singleton. I hate singletons :/
-
@NSGangster You can just do a normal if else, I just like to fuck with the people having to correct the homework
-
A boolean flag would suffice then :) now that static instance will never be garbage-collected. That's how memleaks are made :)
-
inaba46315y@12bitfloat don't 👏 assign 👏 in 👏 ternarys 👏 my dude. Ternarys are not control flow they are expressions
-
If you don't understand ternary operators - don't use them. It's not a shame at all plus you logical expression is quite to complicated to be readable in a ternary expression anyway
-
@c64forthewin I *do* understand them. The code works, it's just a parse error my dude. Not that the code isn't ugly or overly complex. I just don't like how everybody assumes I'm a noob when they don't understand themselves what I'm doing in the first place
-
inaba46315y@12bitfloat I said dick all about it not working so lets take it again and slowly this time.
Ternarys are expressions which means they return something. You use whatever they return in a variable and do with it whatever you want. You are not supposed to use them like ifs because they not statements. You're not using them as designed use an if statement instead because they're designed to do what you're trying to do -
@inaba It's not supposed to be nice code. I just wanted to do it because it works and I want to fuck with the profs, it ain't that hard to understand
Related Rants
-
Cyborg15A guy and a girl are in a Java seminar. Afterward, the guy approaches the girl and asks, "Hey gurrl, can I ge...
-
linuxxx32*client calls in* Me: good morning, how can I help you? Client: my ip is blocked, could you unblock it for m...
-
DRSDavidSoft28Found this in our codebase, apparently one of my co-workers had written this
Am I going crazy or am I just retarded?
rant
wtf
syntax error
java