Hero192 Posted February 11, 2016 Share Posted February 11, 2016 Hey guys, I am kinda confiused between the difference of and and not For example: --Is this correct? When I have to use or and when I have to use and function () if source or isElement(source) then --code end end Link to comment
Mr_Moose Posted February 11, 2016 Share Posted February 11, 2016 All three words: or, and and not may be seen as logical gates. The first two are placed in between two statements that can be either true or false while not just negate whatever statement it's placed in front of. Consider the two lists below with 4 possible outcomes where 1 is true and 0 is false, last number is the result. AND: 0 and 0 = 0 0 and 1 = 0 1 and 0 = 0 1 and 1 = 1 OR: 0 or 0 = 0 0 or 1 = 1 1 or 0 = 1 1 or 1 = 1 NOT: not 0 = 1 not 1 = 0 So your example code would be considered as true if source is defined (could be anything except nil or false) or if source is an element. If you replace or with and however both the statements has to be true in order for the result to be true, ie. source must not be nil or false but source must also be an element, if source is not an element the result is false. Hopefully all this makes sense, it's all about basic logic. Link to comment
Hero192 Posted February 11, 2016 Author Share Posted February 11, 2016 Thanks for your efforts to write down all that to let me understand, btw I got it thanks alot I apreciate that ! Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now