If Else vs Ternary Operator 😍 #ifelse #operator #coding #coder #viral #trending #programming

preview_player
Показать описание
#codewithpatel #programmer #developer #clanguage #python #java
Рекомендации по теме
Комментарии
Автор

I use:

if (condition) return A;
return B;

noco
Автор

I use ternary expressions when I need to assign a value to a variable that needs some logic without adding a few more extra lines

moji_dev
Автор

I always used:
while(if){true}
condition;

Mr_Ghost
Автор

Off course the first one because that is very understable
And I use them always

khushitiwari
Автор

Depends on situation. I usually use ternary to just assign value, if more logic is involved the plain if-else is always safe bet.

anH
Автор

Men with long beard are generally very good influencers🎉

MaheshwarSinha-qqke
Автор

considering the kiss concept I'd go for the 2nd option.
as even after 5 years and having a terrible hangover I can still understand what that block means.

stanislavmikhailiukov
Автор

For better breakpoints adm debugging

if (condition) {
return a;
}

return b;

TobiasOberrauch
Автор

Never judge the code by syntax it should always be judged by logic. Syntax keeps changing version by version, go as simple as possible for readability

mohdzaid
Автор

Personally i like to use both
if/else Statement for code readability and ternary expressions for compactability. As an example in modules where i want to return a string with 2 different vars inside of it

trqb
Автор

I'd choose the one liner if-else when it's simple to use

blueboy
Автор

Using ternary frequently, u will be special in JavaScript.
Using native if frequently, u will comfort to change whatever language used by projects.

deniswarsidin
Автор

Ternary is absolutely help me in design UI/UX with flutter😊

kevinbadboyz
Автор

If it's simple enough, I use ternary one.

nyamnyamo
Автор

Depends on the language, I use whichever is more idiomatic for the language in question. I don't get people bitching about code readability when they see a ternary operator. They should increase their reading skills. Don't be dogmatic about one specific style.

zobayer
Автор

For never to be updated function, left works

itorrestp
Автор

Слева способ для более простых логических операций, поэтому в этом случае лучше выбрать именно его

КириллКрасников-ьж
Автор

I use the right which is being followed by everyone

imnotfeelingd
Автор

If you use a compiled language it doesn't make any difference, but if you use any interpreted language ternary is better

shobharaniheddula
Автор

One is easier to explain one is better for shorter code. Most people who work on projects in a group would want it more simple, but if it is just you and a supervisor to check your work best to go with the shoerter code.

jsuperrex
join shbcf.ru