Why inv==true and not inv=true?



I had the following error at the beginning: (ruby):2: warning: found = in conditional, should be ==
So I modified it and it's now working well but I don't get it ... why the boolean is defined with only one = in my method here: def alphabetique(tableau, inv=false)

And later I've to tell Ruby that if this same boolean is == true, the array has to be reversed ?
Why in this case should we use a double == ?


def alphabetique(tableau, inv=false)
    if inv==true
    return tableau

nombres = [12,55,200,1]

puts nombres



= means assign value
== means check if values are equal


Ok thanks but could you explain to me what Ruby understand when I write if inv=true ?


then it will simply assign true to inv, so you now overwritten whatever was stored in inv, so now this condition is always true


Alright I better not do that then :smile:
I get it now, many thanks @stetim94 for your help !


best not :smiley:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.