Questions tagged [truthiness]

In dynamically typed language, truthiness is a term used to describe a value that might evaluate to boolean true.

99 questions
0
votes
2 answers

Get truth value of column value in sqlite query

If I have a column in a table of zero and nonzero numbers, how do I get the {0,1} truth value of it? Data x, y 0, 111 1, 0 2, 444 (sql query, something like select x, TRUTHOF(y) from Data) Result x, y_truth 0, 1 1, 0 2, 1 Using sqlite3 in python.
ehacinom
  • 8,070
  • 7
  • 43
  • 65
0
votes
1 answer

Conditional value (like while loop) as method parameter

So, I'm attempting to have a method that effectively does this: - (void)doWhile: (/*some magical type*/)condition { while (condition) { // do some magical things } } And while your first suggestion might be a BOOL consider the…
Patrick Perini
  • 22,555
  • 12
  • 59
  • 88
-1
votes
1 answer

Why doesn't typescript object made up of false values return false? Otherwise how can I make it?

I have the following object: const obj = {valueOne: false, valueTwo: false, valueThree: false} and console.log(obj) console.log(Boolean(obj)) // true // true One would think console.log(Boolean(obj) would return false but it doesn't? Is there any…
-1
votes
2 answers

Dictionary Truth Value Testing

>>> dict = {} >>> a=2 >>> if a is not None and dict is None: ... print("lol") ... else: ... print(" Print result is a") ... result is a Why does the first if statement does not run? I am specifying that thedictis empty and that" a"`…
-1
votes
2 answers

Difference between an if statement and an if equals statement

Is there an actual difference between if statement: and if statement == True: Aside from the first one being shorter, does one have a higher precedence, or is one slower? EDIT: I realized this may not have been clear, but statement is usually…
MasterHolbytla
  • 177
  • 1
  • 2
  • 11
-1
votes
2 answers

Ruby Method Arguments - Can they change truth value automatically?

I have this method def forest(sword, armour, ring) with its arguments having true or false values, which I declare in the main program as forest false, false, false If during the program sword=true && armour=true, is there any way for Ruby to…
Sophie Proud
  • 223
  • 1
  • 6
-1
votes
2 answers

Mysterious Cases of Booleans, Equivalencies, and Object Identifiers

First Mystery of Strings: How come bool('foo') returns True? if 'foo' == True returns False 'foo' == False returns False 'foo' is True returns False 'foo' is False returns False Second Mystery of Integers: How come bool(5) returns True? if 5…
-1
votes
2 answers

Is there a string in Perl that is equal to all other strings under eq?

I am running a string equality check like this: if($myString eq "ExampleString") Is there a value that myString could have which would cause execution to enter the if structure no matter what the string literal is?
zztops
  • 694
  • 1
  • 5
  • 11
-2
votes
1 answer

Truthiness test not performing as expected

I have a simple function that tests an item in a tuple to see if it is truthy or not. For some reason all tests come back True (...if connection:...), even though the value being tested is either a 1 (assumed True) or 0 (assumed false). I tested to…
theeviininja
  • 157
  • 7
1 2 3 4 5 6
7