4 ms·
That seems like more of an issue with tuples than with expressive if/else. Tuples are known for having this easy-to-miss disconnection (take for example a funct
by brundolf 5y ago
That seems like more of an issue with tuples than with expressive if/else. Tuples are known for having this easy-to-miss disconnection (take for example a function call that returns a tuple, which couldn't be avoided like the above situation can)
- olodus 5y agoI agree. I feels like this naming disconnect would not exist in this case if you would work with a record/struct. That is what you sacrefice with tuples.
- codefined 5y agolet { value, weight } = if values.empty() { { value: 0, weight: 1.0 } } else { { value: values[0], weight: 1 / values.len() } } Using JS style object expansion, instead of tuple expansion.
- edflsafoiewq 5y agoYou would use a struct here to initialize two variables? The disconnect already exists, multiple variables or many else-if branches just accentuates it.