RUVIDEO
Поделитесь видео 🙏

About Conditional (Ternary) Operator смотреть онлайн

📁 Лайфстайл 👁️ 17 📅 05.12.2023

About the Conditional (Ternary) Operator
November 30, 2022

Today I will discuss a weak spot of mine regarding programming. The conditional operator, also known as the ternary operator, takes three operands and contains a question mark, which separates the first operand and the second operand, and a colon, which separates the second operand between the third operand. The first operand is called a condition, while the second and the third operands are called expressions. I noticed that the ternary operator is also described as syntactic sugar due to its relatively concise syntax compared to the if-else statement. The format of the ternary operator is described as follows:
condition ? expression 1 : expression 2
Despite the mostly identical format of the ternary operator in many programming languages, the syntax of the ternary operator varies from programming language to programming language. In C++ the standard output stream cout, paired with the stream insertion operators , can be used in both operands after the question mark in the ternary operator. However, I found out that in Java, the System.out.println() statement cannot be used multiple times in the operands after the question mark in the ternary operator. Therefore, I think that learning how to use the ternary operator can be quite tricky for programming beginners. Even though some describe it as syntactic sugar compared to the if-else statement, it takes some effort to understand it and code correctly.
The following is the result of my attempt to apply my superficial knowledge of the ternary operator to practice, in both C++ and Java. The output of both programs below are "y is bigger than x" in the console or terminal of an IDE like Eclipse or Microsoft Visual Code. In both programs, the condition of the ternary operator is to compare whether the int variable x is bigger than the int variable y. I found out that both int variables x and y must be initialized before they can be compared in the condition of the ternary operator. In both programs, 5 is assigned to the int variable x, and 7 is assigned to the int variable y. Therefore, variable initialization is identical in both programs. The standard output stream cout is used twice for each time in the two operands after the question mark in the C++ program, but the System.out.println is used only once in the Java program, and this statement also encloses the entire ternary operator with a pair of parentheses, in a similar way to how it encloses strings with a pair of parentheses.
This is my superificial experience with the ternary operator in C++ Java, so take it with a grain of salt.

//C++
#include iostream

using namespace std;

int main() {
int x = 5;
int y = 7;
x y ? cout "x is bigger than y" : cout "y is bigger than x";
}

//Java
public class Java {
public static void main(String[] args) {
int x = 5;
int y = 7;
System.out.println(x y ? "x is bigger than y" : "y is bigger than x");

}
}

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «About Conditional (Ternary) Operator» бесплатно и без регистрации, вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.