ternary Questions

8

Solved

I was wondering if it was possible to do a ternary operation but without returning anything. If it's not possible in Java is it possible in other languages, if so which ones apply? name.isChecked...
Chinua asked 26/2, 2012 at 5:39

14

Imagine I have a class Family. It contains a List of Person. Each (class) Person contains a (class) Address. Each (class) Address contains a (class) PostalCode. Any "intermediate" class c...
Ure asked 30/4, 2012 at 22:29

7

Solved

Is there anyway to use inline conditions in Lua? Such as: print("blah: " .. (a == true ? "blah" : "nahblah"))
Si asked 2/4, 2011 at 20:56

9

Solved

Is it possible to do this on one line in Python? if <condition>: myList.append('myString') I have tried the ternary operator: myList.append('myString' if <condition>) but my IDE ...
Roundtree asked 30/8, 2012 at 14:56

11

Solved

I am trying to simplify the following code. The basic steps that the code should carry out are as follows: Assign String a default value Run a method If the method returns a null/empty string ...
Yorick asked 14/7, 2015 at 16:27

11

I want to use ternary operator without else in C. How do I do it. (a)? b: nothing; something like this. What do I use in nothing part?
Deaton asked 4/9, 2012 at 9:43

5

Solved

Users, I'd like to have some tips for a ternaryplot ("vcd"). I have this dataframe: a <- c(0.1, 0.5, 0.5, 0.6, 0.2, 0, 0, 0.004166667, 0.45) b <- c(0.75,0.5,0,0.1,0.2,0.951612903,0.9181034...
Oruro asked 4/6, 2012 at 9:50

2

Solved

I am using PHP's null coalescing operator described by http://php.net/manual/en/migration70.new-features.php. Null coalescing operator ¶ The null coalescing operator (??) has been added as syntact...
Glassman asked 16/11, 2018 at 17:22

14

First off, the question is "Write a Java program to find the smallest of three numbers using ternary operators." Here's my code: class questionNine { public static void main(String args[]) { i...
Hargrave asked 13/2, 2011 at 20:26

2

I want to evaluate a simple ternary operator inside of a string and can't seem to find the correct syntax. My code looks like this: foreach ($this->team_bumpbox as $index=>$member) echo "...
Emulous asked 4/1, 2013 at 21:27

0

I have a problem for which I have eight elements that can contain 0, 1, or 2. I can easily represent this in 16 bits, but for SIMD efficiency reasons, I need it to occupy 13 bits (it is not the onl...
Symbolism asked 19/11, 2020 at 2:39

3

I've seen this code and need an explanation for "??". I know ternary operators like "?" and then the true-condition and after ":" the false/else condition. But w...
Poff asked 3/11, 2020 at 13:59

5

Solved

My goal is to convert a decimal number into balanced ternary. Converting from decimal to unbalanced ternary simply requires division by 3 and keeping track of remainders. Once I have the unbalanced...
Hyaloid asked 19/10, 2014 at 23:37

0

I am trying to plot data from three columns in a dataframe in a scatter_ternary diagram with contoured datapoints. The columns in the dataframe are Power (W), Speed (mm/s), and Hatch (mm), and I a...
Groff asked 16/6, 2020 at 18:58

7

Solved

I'm trying to convert the following if-else to it's ternary operator representation in javascript as follows var x = 2; if (x === 2) {alert("2");} else { //do nothing} But when I do this: (t==...
Cissie asked 12/8, 2015 at 9:4

4

Solved

I'm currently having some trouble understanding ternary associations in UML. I get the binary ones, but I am unsure how multiplicity works on ternary. I'm doing exercises that I got from my univers...
Breastbeating asked 24/10, 2017 at 18:19

3

Solved

template <typename T1, typename T2> auto max (T1 a, T2 b) -> decltype(b<a?a:b); template <typename T1, typename T2> auto max (T1 a, T2 b) -> decltype(true?a:b); I do not un...
Gadroon asked 25/9, 2019 at 7:33

2

Solved

I know that the XOR operator in base 2 for two bits A and B is (A+B)%2. In others words, it's addition modulo 2. If I want to compute the truth table for XOR operation in a ternary system (base 3...
Crispy asked 4/3, 2017 at 23:27

9

Solved

In this fiddle http://jsfiddle.net/mjmitche/6nar4/3/, if you drag, for example, the little blue box into the yellow box, then the big black box will turn pink. All of the 4 boxes along the left can...
Dextrosinistral asked 6/7, 2011 at 11:24

6

I have a piece of code: if (foo > bar) { baz = foo - bar } else { baz = foo + bar } I have a question if I can somehow shorten this code to a single line, something like PSEUDOCODE: b...
Rowlett asked 8/3, 2019 at 19:24

4

Solved

function foo() { return $result = bar() ? $result : false; } function bar() { return "some_value"; } foo(); Notice: Undefined variable: result Is this a bug? bar() should be saved to $re...
Dying asked 25/3, 2014 at 11:47

4

Solved

In many board games (like checkers, go and othello/reversi) each square can be represented by three states: white, black or empty. 8x8 boards in such game engines are usually represented as two bi...
Axletree asked 10/12, 2018 at 14:53

2

Solved

I have two binary integers, x0 and x1 that are 8 bits (so they span from 0 to 255). This statement is always true about these numbers: x0 & x1 == 0. Here is an example: bx0 = 100 # represented...
Everetteeverglade asked 7/11, 2018 at 19:51

3

Im not quite sure how to read ternary relationships within a ER-Diagram. Lets say this is the ternary relationship that is given. What can I interpret out of that? It says that you have to put y...
Fathometer asked 21/8, 2013 at 19:20

5

Solved

I need to return true or false if an option in a drop down selected. This is my code: var active = sort.attr('selected') ? return true : return false; I get an error that the first retur...
Cotter asked 17/10, 2013 at 23:47

© 2022 - 2024 — McMap. All rights reserved.