In tickscript the norwal way to do if else is in the following:
if(condition, true expression, false expression)
However, for the false expression, I want my code to do nothing as in the following:
if(condition, true print("that is true"), false -do nothing- )
I already tried putting some blank and/or deleting false expression part but it did not work.
Is there a way to do that in tickscript?
Related
This question already has answers here:
Why is a Regexp object considered to be "falsy" in Ruby?
(2 answers)
Closed 2 years ago.
In Ruby, only false and nil are falsey; everything else is truthy. You can use two not operators to check an object's truthiness:
!!false # false
!!nil # false
!![] # true
!!{} # true
!!'' # true
!!0 # true
But then I found that empty-regex literal // is falsey, but as a variable, it's truthy!:
!!// # false!
not not // # false
x = //
x.class # Regex
!!x # true
I think this is a quirk of the parser. How can I ask the parser what it's doing?
This is not just applicable to empty regex literal, but rather all regex literals;
!!/(.*)/
=> false
x = /(.*)/
!!x
=> true
At first this appeared to be an issue with the way the regexp is being constructed
!!Regexp.new('')
=> true
x = Regexp.new('')
!!x
=> true
!!//.freeze
=> true
But digging deeper, this appears to be the cause:
!!//
=> false
$_ = 'b'
!!//
=> true
Setting '$_' back to nil will reset the outcome. The value for $_ is set from Kernel.readline or Kernel.get siblings. In a new console:
Kernel.readline
a
"a\n"
!!//
=> true
So instantiating a Regexp object with // appears to match it against the value of $_
To be honest, I'm not 100% sure, but my idea is that Ruby is doing the next thing when you run !!x
puts !!// # this is doing a phantom .match(nil), like below, so, returns false
x = //
puts !!x.match(nil)
I am trying to build a module that will apply only in conditions when the requirements of the statement are satisfied. In this case if I specify the value for "var.enable_standbyinfra" that is true then the module will be created. I want to understand if I am approaching this type of method wrong or get on the right path
iam_instance_profile_standby = "${var.enable_standbyinfra == "true" ?
module.aem_disp_a_standby_iam.aws_iam_instance_profile_id : 0 }"
and further used in:
iam_instance_profile = "${local.iam_instance_profile_standby}"
The result is that I get an error when running terraform and the error is:
local.iam_instance_profile_standby: At column 3, line 1: true and false expression types must match; have type list and type int in:
${var.enable_standbyinfra == "true" ? module.aem_disp_a_standby_iam.aws_iam_instance_profile_id : 0 }
So the final result I want to get to is that if I specify that "var.enable_standbyinfra" is equal to true the resource is created. If set to "false" I want it to be skipped.
If I posted it wrong without a clear understanding please accept my excuses I am not a expert user in stackoverflow still learning
This argument should be a string, so:
var.enable_standbyinfra == "true" ?
module.aem_disp_a_standby_iam.aws_iam_instance_profile_id : ""
Given three URLS:
http://stackoverflow.com/questionsss/3003310 -> true
http://stackoverflow.com/questionsss/3003310?s=1 -> false (s=1 found)
http://stackoverflow.com/questionsss?s=1&N=3003310 -> false (s=1 found)
How can I write a Regex in JS that returns true if 3003310 is found in the URL and false if s=1 is found anywhere in the URL.
Thanks!
maybe something like this:
^(?=.*3003310)(?!.*\bs=1\b).*
a positive lookahead, and a negative one, for each condition. the \b word boundaries around s=1 prevent false positives such as sass=1 or s=100.
REGEXP:
(.*\?s=1.*)
u should do a method, if result is equal to regex match. it will return FALSE else TRUE.
Original Text:
http://stackoverflow.com/questionsss/3003310 -> true
http://stackoverflow.com/questionsss/3003310?s=1 -> false (s=1 found)
http://stackoverflow.com/questionsss?s=1&N=3003310 -> false (s=1 found)
Result:
http://stackoverflow.com/questionsss/3003310?s=1 -> false (s=1 found)
http://stackoverflow.com/questionsss?s=1&N=3003310 -> false (s=1 found)
Algorithm:
Print(!OriginalText.equals(MethodCheck(Result)) // if empty. it will be TRUE
See: https://regex101.com/r/335HNW/1
I'm trying to make a conditional statement based on whether a checkbox is checked or not. I've tried something like the following, but it always returns as true.
self.folderactive = QtGui.QCheckBox(self.folders)
self.folderactive.setGeometry(QtCore.QRect(50, 390, 71, 21))
self.folderactive.setObjectName(_fromUtf8("folderactive"))
if self.folderactive.isChecked:
folders.createDir('Desktop')
print "pass"
elif not self.folderactive.isChecked:
folders.deleteDir('Desktop')
print "nopass"
Is there a way to get a bool value of whether a checkbox is checked or not?
self.folderactive.isChecked isn't a boolean, it's a method - which, in a boolean context, will always evaluate to True. If you want the state of the checkbox, just invoke the method:
if self.folderactive.isChecked():
...
else:
...
x = self.folderactive.isChecked()
x will be True or Falseāa Boolean value.
(It's the brackets at the end that make the difference.)
Using nodeunit is there an assert to check for false values? Other testing frameworks have something like assertFalse, should I use something like:
test.ok(!shouldBeFalse());
or
test.equals(shouldBeFalse(), false);
Or is there a project that adds a false assertion?
If you want to be sure only boolean false is matched than use strictEqual:
test.strictEqual(shouldBeFalse(), false)
Otherwise equal is ok too.