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
Search - "if -else"
-
Logic Gem found at work today.
if (value != null) {
return value;
} else {
return null;
}
😂 😂😂😂😂😂10 -
public boolean even( int num ) {
if ( num < 0 )
num = -1 * num;
while ( num > 1 )
num = num - 2;
if ( num == 0 )
return true;
else
return false;
}19 -
if (num == 1) suffix = "st";
else if (num == 2) suffix = "nd";
else if (num == 3) suffix = "rd";
else suffix = "th";12 -
So Python doesn't have switch-case statement... I feel so dirty having to use multiple if-elif-else
*sigh*12 -
So sick of my colleague who keeps writing:
if (something) {
doWork();
} else {
}
He insists that it is the best code style to include the empty else clause. WRONG YOU #!*&@!14 -
So I hear Christmas is coming, right? Here's a christmas tree for you!
P.S. this is the real thing. It's a Java project we have to work with... For Christ's sake! The guy who wrote this has recently left the company and handed this code to us as his legacy.
fuck.16 -
Don't know if anyone else saw this on Twitter but this is actual text from Apple's updated app submission guidelines lol11
-
Listen. Use invariants. If you can do
if(!x) {
return foo;
}
...rest of function logic...
Instead of
if(x) {
...some long branch with more tests...
} else {
return foo;
}
Please do. It's so much easier to read when all of your conditions are tested in a line at the top instead of nested 8 layers deep in if-else blocks.
Thanks14 -
I always use brackets for clarity even if there is only one statement inside them
if (boolean){
function ();
}
Cus it's so much easier to read, and if I need to add statements after the if I don't need to remember to add brackets. Plus the else may need brackets and an if with no brackets but an else with brackets looks awful.14 -
When you're typing "make sure noone else is ..."
but your fingers automatically types
"else if"
Damaged beyond repair2 -
AI in a nutshell
if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if if else6 -
if(isStressedOut()) {
procrastinate();
}
meanwhile (somewhere else in the code)...
void procrastinate() {
procrastinate();
}9 -
My team mate has just found the best conditional statement I've ever seen, in a source code he received from the client.
if (1 == 1)... and it has an else branch :D11 -
So my team lead told me in a code review that you shouldn't use 'else if' in code.
Instead you should best them like:
if
else
if
else
if
else
Apparently that would improve readability...
Am I crazy, or what?18 -
What if I've been wrong all the time?
What if everyone else is correct and I'm the one who is raging all the time?
What if I'm annoying you everyone?
What if I'm a very bad developer that everyone hates?
*social anxiety intensifies*4 -
University tells me that I have to indent 4 spaces... If I use anything else I get disqualified...6
-
That just takes the damn fun out of it.
"In Python, we don't actually use commas unlike many languages. And as I mentioned last time, a tuple is a lot like a list, but it has it's differences. Oh yeeeah! Did I mention the logic behind if/else if/ and else statements?? They're sooo amazing."13 -
"I pronounce GIF like 'if'"
"LISTEN HERE, YOU BETTER START PRONOUNCING IT 'JIF' OR ELSE!!!"
"What gif I don't want to?"6 -
Me in a test:
if(boolean)
return value;
return something_else;
I then lost 2 marks for not having an else statement -.-30 -
Just found this while trying to understand some code:
```
bool ok = true;
if(ok) {
// lots of code here
} else {
// even more code here
}
```
I thought this was worth my first rant...6 -
Actual code
if (dict.ContainsKey(key))
{
//do nothing
}
else
{
dict.Add(key, value);
}
I'm speechless15 -
Developers dilemma
If I make something and someone else uses it and it breaks, its my fault.
If someone else makes something and I use it and it breaks, its my fault.1 -
Developers who writes something similar
if (count >= 0) { return true; }
else { return false; }
deserves a special room in hell.16 -
YOU: if(exp){ statement 1;} else { statement 2;}
v/s
THE GUY: exp ? Statement1 : statement 2;
She says not to worry about!!9 -
no matter how big shot programmer you are, you 90% time you will only code
if(condition)
{
// do something
}
else
{
// do something else
}8 -
// Just in case
if ($scope.currentPlatform === 'android') {
$scope.enableDatePicker = true;
} else {
$scope.enableDatePicker = true;
}5 -
I have previously seen this in a production code base. The same code base included nested if statements (20+ conditions)...
If (condition == false) {
return false;
} else if (condition == true) {
return true;
}11 -
/* MacOS source code
Copyright Snapple, Inc
Private and confidential */
void resumeFromSleep() {
if (rand() > RAND_MAX / 2) {
freezeSystem();
} else {
reallyResumeFromSleep();
}
}4 -
Your mind is programmable - if you're not programming your mind, someone else will program it for you.8
-
Good news everyone!
unset ($marriage);
If (isset ($marriage))
self::sadness ();
else
Self::joy ();13 -
If (index == 3) {
return true;
}
else {
return true;
}
Apparently the number 3 is magical or aomething.7 -
if (MONTH === 1 & DAY === 18) {
alert("Bro, it's your birthday");
} else {
alert("Bro, just go away, you're nothing special 😅);
}12 -
found this in our codebase today
try {
//do something
} catch () {
try {
//do something else
} catch () {
try {
//do something else else... this goes on 4-5 levels deep
} catch () {
//log... couldn't do
}
}
}9 -
OMFG if I see one more single-lined if-else/for statements without proper closure brackets I'm gonna kill some people!!!8
-
Company : we added AI to our product!!
What i hear : we added a sequence of if and if else to our product 😂😂5 -
Is this just me?
if(..... expression.....){
System.out.println("it works, calm down");
} else{
System.out.println("it's not fucking working, holy fucckk, fucking WORK");
}
Tell me if you do something similar.6 -
bool True = false;
bool False = true;
if (True == true)
{
False = True;
}
else
{
True = true;
False = !true;
}
if (!False == !!true && True == !false)
{
False = True;
True = (!!False)true;
}
Console.WriteLine("Banana");5 -
public function recruiters($salary)
{
if($salary == "competitive")
{
return NaN;
} else
{
return "What is the real salary?";
}
}3 -
Started a new job this week.
Just learned that my manager strictly prohibits while loops and "if else" statements.23 -
Told juniors about coding guidelines that don't put another if-else just to fix a bug. Think through about it and see if you can come up with better solutions.
Today one bug was filed, they asked what happened, one junior said that he [my name] asked me for no if-else in code. He kinda deleted all if-else in codebase and started using same implementation for everything.
I'm standing with a WTF face.
😐8 -
Checking out new editors:
if (editorHasTheme('SpaceGray')) {
installEditor();
} else {
checkNextEditor();
}11 -
Close all IDEs.
Then...
if (needs_music) {
open.production("fl_studio");
} else if (needs_engine_roar) {
open.game("fsx");
} else {
open.systemapp("Task Manager");
kill.all("processes");
computer.shutdown(5000);
}6 -
What's the point of abstraction layers if you're riddling all the code with
if (AbstractionLayer.SomeType instanceof ImplemantationLayer.SomeTypeIml1) {
// do stuff
} else if (AbstractionLayer.SomeType instanceof ImplemantationLayer.SomeTypeIml2) {
// do stuff
} else if (AbstractionLayer.SomeType instanceof ImplemantationLayer.SomeTypeIml3) {
// do stuff
} else if (AbstractionLayer.SomeType instanceof ImplemantationLayer.SomeTypeIml4) {
// do stuff
}
???
Seriously.. Guys. Am I missing some point here?9 -
Else if, elif, elseif, if else garrgghj. I can never remember what it is in whatever language I happen to use...13
-
If god was a programmer, do you think he made us like
int sex = rand()% 2+1;
if (sex == 1){
std::cout << “it’s a girl!”;
}
else if (sex == 2){
std::cout << “its a boy!”;
}17 -
the first code on every samsung app
if(enoughSpace())
run()
else
annoyUserWith(new Popup())
closeApp()3 -
That time you waste hours searching through a perfectly good method. Turns out the outcome is overridden because you forgot an else in an if-else statement....
-
public void 2016(){
if (badLuck = NOT_ENOUGH)
badLuck++;
else
badLuck++;
}
public String 2017(){
return HOPE_FOR_THE_BEST;
}
Happy new year fellow programmers!6 -
if ( condition ) {
callback(data)
}
callback(error)
--is a lot different than--
if ( condition ) {
callback(data)
} else {
callback(error)
}
callbacks are not return statements 🤦♂️9 -
Anyone else here thing their head would explode if they knew something like this at their workplace?8
-
My first login function
const login = (email, password) => {
If (email && password) {
return true
} else {
return false
}
}10 -
I have one confession.
I have never ever in 15 years of coding used switch case...
Never liked the syntax.
Am i the onlyone ?17 -
int counter=0;
void loop()
{
if (counter>=10)
{
// nothing
}
else
{
Serial.println(counter);
counter++;
}
}
This is what I call bureaucracy3 -
Today I found this jewel in a PR of a respected dev of my workplace:
if(conditions)
{
return true;
}
else
{
return false;
}3 -
Ask yourself as you plan the meeting:
1. Is an email a better solution to this?
If the answer is yes, plz just send the fucking email. Else, try and find a way to make it an email instead. If all else fails then yeah go ahead and have your stupid meeting. -
At the University, Algorithms class, exercises lesson..the assistant explaining the results of an assignment:
"Because here..if we use a classic 'if-else' loop..."
😳1 -
When you find out you didn't need that if-else statement in your code if you simply made an additional variable with an expression that works for all cases of that if-else statement
-
If ($shit_hits_fan='true') {
$_GET['vacation'];
} else {
echo 'it was like that when I got here';
}6 -
I really dislike when people don't use braces { } on if/else statements.
If(almond.harvestStatus == undefined) almond.harvestMode=false
almond.dropdown = false.2 -
Being the dumbest smart person is way better than being the smartest dumb person. Here is looking at anyone ever trying to tell me how to do my job yet you cannot read a fucking error messag. Yes incorrect password means you got it wrong, dim witted cunt
-
When you find this in the PHP code:
if(condition) {
// code
} else {
die('horrible death');
}
Cheers to the fellow devRanter who added it and also to whoever is going to get to "else" part :D1 -
include <studio.h>
int year;
int main(){
if (year==2016){}
else{
printf("Happy %d!!",year);
be happy;
}
return 0;
}6 -
I help first year Computer Science students at my uni. In the first few weeks I reviewed someone's code to find he had 253 variables called var1, var2, var3 and so forth. The even worse part: he made the same if-else structures for every variable without using a loop.
if (var1 == something) {
//huge chunk of code here
}
else if (var1 == something) {
}
else {
}
... var2... var3
The funniest thing about this is that we had a discussion about this, because he claimed this was the right way to solve his problem.5 -
what is the else there for, it reminds me of all the times I saw shit like
if(variable == true){
}else{
doSomething();
}8 -
Trying to figure out the average age of devRant users.. So..
if(user['age']<6){
$score--;
else $score++;6 -
Coffee coffee = new Coffee { };
if ( coffee.Empty )
{
coffee.Refill ( );
}
else
{
coffee.Drink ( );
}
// I'm a software developer \\9 -
So I wrote a python code and was waiting for +1 on code review and I needed to merge it fast. That shit of a reviewer took his time to finally NOT give a +1 with comment, "if statement has no else part". OF COURSE IT DOESN'T HAVE ELSE PART. I DON'T NEED A ELSE PART. But to give him the benefit of doubt, I'd like to ask devRant community if they believe all ifs should have elses.14
-
Use different indentations in same program.
for(.....) {
}
if
{
}
else
{
}
void doSomething
{
}
static{
}
I have to stick to one convention anyhow soon.. :/3 -
At first it seemed harsh, but then I learned that he committed code like
if (a == b)
return true;
else
return false;9 -
Code of developer's life
int f = 1;
If( life == "smooth")
problems();
else if( life =="hard")
{
problems();
breakup();
}
else
{
while (f = 1)
{
bugs();😣
}
}15 -
When you have to made a little game with javascript, and because it's your first game you made a beautiful maze with lot of wall.
Ahahah... i'm shit.
I forgot wall have collision.
I'm here now, with 40 different fuckin' walls and much if and else if conditions.
I hate me.
Yeah i know, I can just change my maze but no... I'm lazy. Cry against the collisions is better.
Have good day.9 -
bool isTrue(bool val){
If(val == true){
return true;
}
else if(val == false){
return false;
}
else{
cout<<"Wrong value";
}
Function isTrue is the future ! 😂😂😂2 -
//Doing $hit to get stickers
Rant r = new Rant();
if(r.isSeen()){
if(r.PLUS < 30){
r.plus();
} else{
r.ignore();
}
}7 -
Found this in production code.
For those who doesn’t understand Delphi:
switch (some boolean) {
case false:
// some code
default:
// some code
}7 -
Mind blow of the week: JavaScript has no "else if".
It's always two tokens. Not one. It's NOT like python's "elif".
It's ALWAYS chaining an additional and DISTINCT if statement in the else clause of the first. It is NOT creating multiple comparison paths in the same if statement as it would seem.
For example:
if(a) console.log(a);
else if(b) console.log(b);
else console.log(c);
Simply needs more proper indentation to show which "if" the "else" actually belongs to:
if(a) console.log(a);
else
if(b) console.log(b);
else console.log (c);9 -
Anyone else hates this kind of statements:
if ( doSomething() != SUCCESS ) {
//log error
}else {
//continue doing other stuff
}
I simply find that confusing. This is much better:
If ( doSomething == SUCCESS ){
//continue doing other stuff
}else {
//log error
}
Maybe just my opinion.17 -
allUpperCase = true
for char in rant.message:
if !isUpperCase(char):
allUpperCase = false
if allUpperCase:
rant.category = "rant"
else:
rant.category = "!rant"6 -
var myLove =0;
var myLife = 'you';
if(yourHeart =='Me'){
myLove =+1;
else {
myLife = null;
myLove = undefined;
}4 -
function myLife(time){
if(time.current() < time.alarm1)
sleep();
if(time.current() = time.alarm1){
wakeUp();
if(tired || hungover){
snooze();
sleep();
} else{
getReady(speed.Normal);
goTo(work, speed.Normal);
doMyJob(function(){
goTo(home);
});
}
}
if(time.current() = time.alarm2){
wakeUp();
if(tired || hungover){
snooze();
sleep();
} else{
getReady(speed.Fast);
goTo(work, speed.Normal);
doMyJob(function(){
goTo(home);
});
}
}
if(time.current() >= time.alarm3){
wakeUp();
if(tired || hungover){
workFromHome();
} else{
goTo(work, speed.Fast);
doMyJob(function(){
goTo(home);
});
}
}
}3 -
I hate complicated and out of date documentation!!!
if (me == angryClickityClackity) {
headButtKeyboard = True;
}else{
headButtKeyboard = false;
}15 -
Do
{
// TODO: Do some proper naming
var myEgg = new Egg();
if(firstRun)
{
Paint(myEgg, red);
}
else
{
Paint(myEgg, randomPaint());
}
}While(isEaster()) -
class Bug():
def __init__():
self._fix = random.randint(1, 6)
def fix():
if self.is_feature :
return Feature(self)
else:
if random.randint(1, 6) == self._fix:
Bug()
del self
else:
return Bug() -
if (smart === false) {
system32.delete();
} else if (smart === true) {
system32.DEMOLISH();
}
MUAHAHAH5 -
Was reading about FizzBuzz/Algo again and I guess the modulo run-time.
The most optimal solution I came across is like:
if (x % 15) FizzBuzz
else if (x % 3) Buzz
else if (x % 5) Fizz
else x
But then how long does % take? Should you care?
I was thinking it should use variables:
var f = x % 3 == 0
var b = x % 5 == 0
if (f && b) FizzBuzz
else if (f) Fizz
else if (b) Buzz
else x10 -
If(DateRightNow == 16/07/2018)
{
Age++;
LifeTime--;
}
Else
{
NoRealizationThatEverydayLifeTimeDecreses;
}18 -
const silicon_valley = true;
if(silicon_valley == true) {
watchSiliconValley();
} else {
work();
}
// yeah I know it's crappy1 -
A programmer's wife sends him in a grocery store with instructions "Get a loaf of bread, and if they have eggs, get a dozen". He comes back with a dozen loaf of Bread and Tells her "They had eggs"4
-
That moment where you see code of someone who riddles their code with nested if-else and if-elseif statements.
I don't remember writing an else statement for years. It almost always can be avoided (and the rare cases where it makes sense I prefer the switch statement).
Yet I never grasp why people do:
```
if(someCondition) {
// huge nested code block
} else {
throw new Error();
}
```
Instead of
```
if (!someCondition) {
throw new Error();
}
// continue in the normal scope
```
And then we have experts that like doing:
```
if(someCondition) {
if (bar) {
$foo = 'narf';
} else {
$foo = 'poit';
}
// huge code block
if($foo == 'narf') {
if(yetAntherCondition) {
// huge code block
} else {
throw new Error();
}
// huge code block
} else {
throw new Error();
}
} else {
throw new Error();
}
```
Help!
If ever was to design a programming language, I'd forbid the `else` and `elseif` keywords. I have yet to find an instance where I could not replace some `else` by either a guard or an early return or introducing some polymorphism.1 -
Benefits of using Strings for Boolean intended logic?
I'll go first
easily implement cases before finally checking if true
generateUsername: { type: String }
if(generateUsername == 'humanReadable'){
// generate a username in a human readable format AKA yoDudeImRainbow
} else if(generateUsername == 'hash'){
// generate a username by using a random hash
} else if(generateUsername){
// generate a username by using a random hash
}21 -
"If all else fails, [working harder than anyone else] is the greatest competitive advantage of any career." - John C Jay
-
"Never stand still. If you stand still, you get lost, because someone else is always moving. " - Armin Vit1
-
function toCodeOrNotToCode() {
if (!isset($coffeeOrRedbull)) {
die('No work can be done');
} else {
return true;
}
}
// I don't drink Redbull daily4 -
//I find a couple beers after hours relaxes the mind enough to work through the problem. aka The Ballmer Peak.
while(stuck == true) {
if(time < endDay) {
console.log("Keep working");
} else if(time > endDay && beers < 2) {
beers ++;
} else if(time > endDay && beers >= 2) {
stuck = false;
}
}1 -
while project != Finish :
if stomach == full :
keepCoding()
else :
orderPizza()
if project == Finish
goOut()
(Fyi, can't indent here. LoL. I am glad there isn't python around to blurt errors on my face 😂)8 -
It's my birthday and....
if(Birthdate.Date == DateTime.Now.Date)
Console.Writeline("HPD - Muli");
else
Console.Writeline("Try again Tommorow");3 -
The second you write `else { return false; }` you should lose the privilege of calling yourselves a dev, from then on. Period.
Example,
if(condition) {
// ...some code
return true;
} else {
return false;
}14 -
How do you deal with relatively complex Boolean logic requirements?
Here's a simple example, of which I missed 50% of the cases because it was non-intuitive to me:
A year is a leap year if:
- it is divisible by 4
- except it is also divisible by 100
- unless it is also divisible by 400
To my intuition, the logic tree is as follows:
if (year % 4 == 0) -> true
if (year % 100 == 0) -> false
if (year % 400 == 0) -> true
so I ended up with 3 cases and I initially missed all the others until I started coding.
The full solution is:
if(year % 4 === 0) {
if(year % 100 === 0) {
if(year % 400 === 0) {
true
} else {
false
}
false
} else {
true
}
true
} else {
false
}
}
I don't like it when I don't immediately see all logic paths.19 -
//Happy Monday!
if (DateTime.Today.Contains(school))
{
athlon.Location = new Point(school_X, school_Y);
studyUselessThings = true;
}
else
{
code = true;
}2 -
Do you prefer?
var foo = true;
if (some condition){
var foo = false;
}
Or
if (some condition){
var foo = false;
}
else{
var foo = true;
}9 -
Else Heart.Break() has anyone else played this if not. Strap on your modifiers and pick you up a copy because this game is full of spark.4
-
1. Commented code instead of actually cleaning it up.
2. Returning default return variables instead of rewriting obsolete code. (Generally if/else conditions with return). So instead of removing the if/else statements i return default value(null or empty objects). This is when the case of if/else will never arise. -
if(this.rant.value < 69)
RequestToReader("Please give upvote");
else if(this.rant.value > 69)
RequestToReader("Please give downvote");
else
RequestToReader("Comment: 'Yeah, Party!' "); -
class smoking{
public static void main ( String []args){
int a = 2;
String c = "cigarettes";
if (a==2)
System.out.print ("go smoke "+ c);
else if (a <2)
System.out.println ("go buy some");
else
System.out.println ("error");
}
}10 -
" Under the hood... the program is using a mix of condition-based learning, procedural generation of sentences/questions, and relational queries based on weighted 'topic' identifiers. It can create its own original statements and questions. It is real-time, and it really does 'think' (an internal dialogue feedback loop)." = If Statement
I saw this in the description for an app aclled "Real AI" -
My Coding Loop :
while (working) {
coding();
createNewBug();
if (bugs != 0) {
fixTheFuckingBugs();
if (bugs != 0) {
fuckMySelf();
} else {
continueWorking();
}
}
}1 -
What do people like more?
if(condition){
return true;
} else{
return false;
}
Or just
if(condition){
return true;
}
return false;7 -
like = 0;
if( youare == "awesome")
{
like = like + 1;👍
}
If( like >= 30)
{
getstickies();😍
}
else
{
printf("Oops!! Next try!!!!");😫
}11 -
Has anyone else noticed that the items in the avatar builder load extremely slowly, if at all? Or is it just me?3
-
Coffee coffee = new Coffee();
If (coffee.Empty)
{
coffee.Refill();
}
else
{
coffee.Drink();
}
//I am a software developer
//Coffee addicted3 -
Whoever wrote this line of code... please take on a different profession.
`else if len(LEFT({ODWR_CLAIMSNAPSHOT.POLICY_TYPE}, 3)) > 0 then`6 -
Not loving the implicit return statement within Scala. I like to avoid else statements to keep the level of nesting low and do early return yet Scala doesn't allow that.
(I am aware that I should flatMap that shit though in some cases I just want a simple if not foo then throw exception line. And continue with the next block until I return something.)
So you either have to create if-else-nesting beats or use pattern matching. The latter seems overly complicated for this use case (though it has its moments).
I know that I can make the return explicit yet the linter warns against that. It feels so verbose and I currently do not see any benefits and would argue that the code becomes both harder to read and maintain.3 -
The key to any good relationship is compromise. Ladies and Gentlemen, allow me to introduce the 2-4-tab alternating space indent style!
if (x) {
somemethod();
}
else if (y)
{
someOtherMethod();
} else {
iDontKnowHowToTabOnAndroidMethod();
}5 -
That's gonna be a quick rant about Golang.
Anyone else here frustrated by the fact that you can inline assignment in the if statement, but can't inline the if-else itself?
You can do:
if thing := hey.getThatThing(); thing == theThing {
return 'this'
} else {
return 'that'
}
But can't do:
return 'this' if hey.getTheThing() == theThing else 'that'
Or is it just me using too much Python everyday and connecting that with Go in free time?5 -
The feeling when client mails appreciation for a simple if else, but doesn't bother when you implement complex cycle detection algo.
-
“20” twenty static code if conditions...
if() {} else if(){} else if(....
with static code contains the different names of some users... and he still thinking that it the best way to do it!!!! -
Devs around the world, raise your salary, if you know your shit. Don't lowball, if they hesitate find someone else who will.
-
I do contracting for different companies who get too much work on their hands and a deadline on their ass, and it’s always a trip to see how amateurish some of their developers are.
Like who the fuck names a major variable ‘abc’ or ‘xyz’ !!!!
Also they clearly don’t know how to ask equivalence if statements as I got a chain of if else statements that were written like
if (decision>0 && decision<2)
//Code
else if (decision>1 && decision<3) ...etc1 -
public String findHappiness()
{
if(EverythingOk)
return “Drink Beer”;
else if(EverythingNotOk)
return “Drink Beer”;
else
return “Drink Beer”;
}1 -
Fizzbuzz
for (var num = 0; num <= 100; num++)
if (num % 3 == 0 && num % 5 == 0) {
console.log("FizzBuzz");
}
else if (num % 5 == 0) {
console.log("Buzz");
}
else if (num % 3 == 0) {
console.log("Fizz");
}
else {
console.log(num);
}11 -
Hell will break loose even if you deploy your shit on monday morning and noone has anything else to do.
-
A random thought.
In a game what if we put these messages instead?
If a person wins, "We have a winner!"
Else, "We have a weiner!"1 -
Anyone else here a high school student that does programming for an FRC team? If so, what number? Also, what language?11
-
def devRantPostAction(post : DevRantPost) = {
If ((post.contains("fuck") && ContradictsItself(post)) || ContainsBrilliantGif(post) || ReferencesPornSite(post))
PlusOne
else if (ContainsSqlInjection(post)
MinusOne
else
Ignore
} -
First assignment after I learned about if-else-then and for loops: draw swastika with modifiable width variable2
-
When white space isn't that significant.
disc=b*b-4*a*c;if(disc<0){
num_sol=0;}else{t0=-b/a;if(
disc==0){num_sol=1;sol0=t0/2
;}else{num_sol=2;t1=sqrt(disc/a;
sol0=(t0+t1)/2;sol1=(t0-t1)/2;}}2 -
Def processCurrentDay(work):
If work.field == "retail":
While work.status == "unsatisfactory":
Work.do_work_things()
If work.status
=="exceptional":
Society.bioengineerFlyPigs()
else:
processCurrentDay(work) -
I needed to implement user authentication on an android app during ny internship. It always authenticated and ran code for not authenticated user. Turned out I wrote else instead of an if else.
-
var me = new Developer();
while(TimePassing())
if (time > 9am && time < 10am)
{
bool success;
me.TryStayAwake(out bool success);
if (success)
me.Code();
}
else
{
if (bedtime)
me.ActivateSuperAwakeMode()
}1 -
if reverse_engineering > coding_from_scratch:
more_fun()
else:
also_fun_but_not_so_l33t()
resp = input('anybody feels the same?')
# hopefully pep8 compliant1 -
if (in_array($needle, $haystack)){
return true;
}else{
return false;
}
# yeah, I did it.... wtf brain!!1 -
So for anyone else out there that is learning WPILib for FRC. If you ever use ctre/Phoenix motors (don't know if that's a rule) DO NOT EDIT <ctre/Phoenix.h> HOLY2
-
"Never do anything yourself that you can hire someone else to do, especially if they can do it better." - Bill Bernback
-
devRant Experiment:
if (abovePost().plusPlusCount > thisPost().plusPlusCount) {
thisPost().plusPlusCount++;
}
else if (belowPost().plusPlusCount < thisPost().plusPlusCount) {
thisPost().plusPlusCount--;
}1 -
{
while(time_to_exams > 0){
me.shouldBeLearning(true);
time_to_exams--;
}
public void shouldBeLearning(boolean bool){
if(bool){
should_be_learning = false;
waste_time_on_DevRant = true;
} else {
waste_time_on_DevRant = true;
}
}
} -
"If... else" Artificial Intelligence
because it's not self efficient but limited to the developer's logic. -
In javascript, is there a difference between separate function calls that mimic a "chain pattern" or state changes using if/else if/else and using the chain or state pattern directly? The internet gave me no real/helpful response to that.
Suppose that:
if(isThingA(thing)) {
makeThingB();
else if(isThingB(thing)){
makeThingC();
else {
makeThingA();
}
That code is always executed e.g. after a user mouse click. "thing" gets defined in some other code.
It can be seen as a state machine that goes back to its starting point.
Is a pattern with objects/classes/prototypes even needed/preferred instead?
It's partly a problem I'm facing in my code but it's also interesting to know ideas/thoughts on this.3 -
How to code a translator:
public string Translate(string input, string lang)
{
if (lang is string)
return input;
else throw new NotFoundException();
} -
https://notalwaysright.com/server-i...
Not sure if anyone else has linked this yet but this sounds way too familiar -
Some developers just want to annoy other developers
`var IS_DEV = true
if(!IS_DEV) {
//do stuff for production
} else {
//do stuff for dev
}`
Why don't you just do `if(IS_DEV)`...1 -
abstract class Ich {
abstract void support(CoWorker coWorker);
abstract void programm(List<Task> tasks);
abstract void analyseCode(String code); // mostly horrible code
abstract void drinkCoffee(Mug mug);
abstract void extinguishFireAndKillBugs(String moreLegacy);
}
...
void work() {
ich.drinkCoffee();
while(isWorkingTime()) {
int rand = Random(0,100)
if(rand < 5) {
ich.myMood += ich.programm(tasksForMe);
} else if (rand >= 5 && rand < 20) {
ich.myMood -= ich.analyse(legacyCode);
} else if (rand >= 20 && rand < 40) {
ich.myMood -= ich.support(GetNextGuyToMe())
} else {
ich.extinguishFireAndKillBugs(moreLegacyCode);
}
if(myMood <= 0) {
ich.gotoHome();
}
}
}1 -
Followup to https://devrant.com/rants/2178597/...
It gets worse.
`if len(Replace({ODWR_CLAIMSNAPSHOT.LIMIT_DESCR}, '/', '-')) > 0`5 -
I feel like an imposter because ...
I forgot that in Ruby, it's "elsif" and not "else if" today. How about you?2 -
If someone tries to convince someone else to try X framework, should they be called X missionary?
(asking for a friend)2 -
So, are we gonna ignore the fact that Pied Piper could have been successful, had they used if else on the encryption to block the AI from tampering with an encrypted data?3
-
I believe ternary operators should be banned in python/ruby. They are confusing, irrelevant and people use them in bizzare places.4
-
If I wanted to write some article about code, where would you prefer to read it?
Medium? Dev.to? Something else?14 -
It's so easy to use for-each loops instead of if-else chains, yet when I write a system in for the first time, I always find myself doing the latter.
"It's placeholder code" saves me every time as long as I rewrite it later.6 -
Time since the last bug caused by blindly copying code in a if/else and forgetting to change a variable: 0 Hours.
-
People hate on Python a lot. I just used the Python ternary operator for the first time. I found it easier to read than the C++ ternary operator:
0 if i==0 else 2 if i==segmentMax-1 else 1
vs
i==0 ? 0 : i==segmentMax-1 ? 2 : 1
I think Python did a good job in this case.18 -
I once declared and initialized a variable with a default value all together. (var a= "default";)
And in a certain IF condition the variable value has to be changed, so i was changing the value of the variable inside IF condition. If (x==y) { a=" newVal" ;}
During a code review i was asked why i am not assigning the default value in ELSE condition. And i was like whut 😑.
So........ Some Programmers be like IF shouldn't exist without ELSE.6 -
if (person1 === person2)
{
point at the cockroach being squashed
}
else
{
do the same stupid thing
} -
If(social_Life){
System.out.println("you are not developer");
}else{
System.out.println("You are Developer");
}1 -
Count the fingers on both hands
if it comes 10 then f**k u
else if it is < 10 you are definitely a programmer.14 -
really??
if(fisYear == "" && fisMonth == "") {
} else {
$scope.yearType = fisYear;
$scope.faPV.month = fisMonth;
} -
is it bad to put your jsx in useState for react?
const = handleClick = (sort) => {
if(sort.props.id == 'default'){
setSort(<ArrowUpward id='up'/>)
}
else if(sort.props.id == 'up'){
setSort(<ArrowDownward id='down'/>)
}
else if(sort.props.id == 'down'){
setSort(<LineAxis id='default'/>)
}
}
the other alternative is using template logic which i think looks uglier, someone told me i did server side rendering in the browser2 -
void main()
{
if( isWeekday() ) {
if( alarmRinging() || kidsKnocking() ) {
startMorningRoutine();
escapeToOffice();
while ( !meetingsInProgress() ) {
code();
} //meetings interrupt the whole day, every time...
escapeMeetings(); //Go home.
startEveningRoutine();
} else {
sleep(1);
}
} else {
playWithKids();
doYardWork();
if( kidsSleeping() ) {
sleep(1);
}
}
} //end main. Like a microcontroller, this forever loops. :) -
Who writes something like this!?!?
if (result == "True")
{
return "True";
}
else
{
return result;
}1 -
void intDatetostr(char *strDate, int intDate) {
if (intDate == 0) {
sprintf(strDate, "%09ld", intDate);
} else {
sprintf(strDate, "%-09ld", intDate);
}
}2 -
num = float ("input a number:")
if num>0:
print ("it is a positive number")
else num=0:
print ("it is zero")
else:
print ("it is a negative number")1 -
private boolean didWakeUpForNothing() {
if (mathTutoring.isClosed()) {
return true;
} else {
studyForExams();
}
}
private void studyForExams() {
feelEmptyInside = cryInShower = true;
}1 -
while(!Success)
{
finals.toStudyFor();
if(Dead||!(finals.toStudyFor))
{
up.wake;
finals.toStudyFor();
}
else
{
home--;
family.disown();
life.fail();
}
if(Success)
{
down.lie();
notToCry.try();
cryALot.do();
celebration==true;
}
} -
while (optimistic > knowing)
megaUsefulOptimize.run()
if (truth.found())
{
shout.start(developer.LEAD)
}
else
{
secret.timeWasted++;
this.message("you're doing the right
thing man");
} -
When you want to investigate what a function does, you read the name and say "ok, seems reasonable what it should be doing" ... and then you encounter an adventure of if-else's, nested if's and else's, some promises here and there (with more nested if's and else's) and also a bunch of dispatches sprinkled all over the place. You want to refactor it into tinier functions but can't because you don't know what happens where ... help ... 🙄😩
-
If (true) {
// do else action instead
} else {
// fallback code
}
...no one else is in the pod, I "could" open a bottle, but I also have a deadline. X-o -
while not all(pokedex):
for k, v in pokedex.iteritems():
if v:
feelings = get_satisfaction()
else:
pokemon = find_em()
try:
new = catch_em(pokemon)
except PokemonEscaped:
continue
else:
pokedex[k] = new
feelings = get_satisfaction() -
i can never understand the theme behind kotlin.
THEY DON'T HAVE A FUCKING TERNARY OPERATOR!!![?:]
Like before realizing this, i thought yeah jetbrains has decided to make android development a privileged hobby and non beginner friendly , so its now creating an encoding like language, in the false theme of " reducing code size"
But now they remove WORLDWIDE KNOWN, OPTIMIZED , EASY TO READ AND USE AND UNDERSTAND FEATURE of ternary operator and replacing it with less powerful but same looking elvis operator.( and stating that using if else for that is a better option)
Like why? if your goal is to make a shitty encoding language that makes everything shorter and most of the things optional, why remove the already efficient if else encoder?
God knows when this stupid language is going to stop my brain from getting blasted11 -
if( this.review(this.rant) == "++" ) {
echo ( this.name . " is awesome" );
} else {
echo ( "FUCK". this) ;
}5 -
If (method-exists (devrant->rantAboutBreakingUpWithGirlfriend ()){
Echo "This seriously sucks %#$@£¥";
}else {
Return false;
}