R
R
rileySalander2016-02-08 02:01:52
C++ / C#
rileySalander, 2016-02-08 02:01:52

Shorthand if?

return  a.size() == b.size() ? a < b : a.size() < b.size();

Good day, can you tell me how to write this with the usual *if with else*

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stalker_RED, 2016-02-08
@Stalker_RED

This is a ternary operator.
In expanded form it will be like this:

if (a.size() == b.size()) {
    return a < b;
} else {
    return a.size() < b.size();
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question