Hello everyone this is more of a general programming question. I am trying to understand why VC uses lambda keyword in condition functions. for example this script runs fine.
a = 1
b = 5
def logic(x,y):
if x < y:
return True
else:
return False
def OnRun():
print "test"
print "is ",a," less than ",b
print logic(a,b)
condition(lambda: logic(a,b))
print "passed"
but if I remove the lambda key word it will not get past the condition function. I really don’t understand why this is.
the logic function returns a value of true or false, and the condition function requires a value of true or false in order to resume the script running so why does it need the lambda keyword.
I read up alot on lambda in python but all I seem to find is that is used for anonymous functions.
that is to say functions without names with out using the “def” keyword.
ex
lambda arguments : expression
but here in VC components we define a function of name logic.
and then we use lambda to call that function by it’s name. it just doesn’t make sense to me why.
if anyone can shed some light I would greatly appreciate it.
Thanks