I am new to ruby and working on a tutorial but not sure what this line of code means:
[movie, version_number].any?(&:nil?)
From my research, Array.any?returns true if any of the elements in the array is not falseor nil. And &:nil?means a call to_proc()to the :nil?ie symbol :nil?.to_proc, therefore the operator is equivalent
[movie, version_number].any?(:nil?.to_proc)
which is equivalent
[movie, version_number].any?{|item| item.nil?}
Next, any?Skips each item in the collection (in this case, Array) into a block {|item| item.nil?}.
When you add them together, does a line of code mean, call nil?for each element of the array before calling .any?in the array, i.e. it is equivalent:
[movie.nil?, version_number.nil?].any?
Or, in plain English, is there any movie or version_number equal to nil?