Precedence of and/or versus method arguments in ruby -
Here are two tests:
if included [1,2,3,4] ? 2 & amp; Amp; Nil.nil? Says: Hello Ends # = & gt; and
if [1,2,3,4] .include? (2) & amp; Amp; Nil.nil? Says: Hello Ends # = & gt; Hello The above tells me that compared to the law code, , 3,4] .include? 2 and zero Indigo? Says: Hello Ends # = & gt; Hello So it is telling me that the method argument and ' Note: I understand that I can not find this document which confirms this, for example, this method does not exactly mention the arguments: or. Can anyone explain this behavior? In other words, how does Ruby know how to pass values in the form of arguments for a method versus process operators? & amp; Amp; & Amp; Amp; Amp; & Amp;; is a high priority, so it's logical and 2 & amp; Amp;
What is [1,2]? and ' are the same priorities (or the argument of the method ' and >) Because it contains 2 to include? Before this 'and' processed. & amp; Amp; and and have different priorities. The question is not about this, but about it and or or Method.
As you have said that and and and < / Code> have different preferences, though the explanation for the following example:
if [1,2, 3,4] .include? 2 and zero Indigo? Says: Hello Ends # = & gt; Hello and have the binding power as you can read here:
It basically tells that 2 more Zero. Zero will be assessed as zero, although it can be seen in this example back as 2:
foo =: foo bar = nil a = Foo and bar # = & gt; Zero = # & gt; : Foo a = foo & amp; Amp; Bar # = & gt; Zero = # & gt; Void
Comments
Post a Comment