title: How can I create a Proc to checking whether the elements of an array are nil or not?
body: <p>I'm trying to solve this assignment:</p>
  <blockquote>
  <p>Create a Proc that will check whether a given array of elements are nil or not. Use <code>.nil?</code> to evaluate elements. Print 'true' if the elements are <code>nil</code> and 'false' if the element has a [truthy] value.</p>
  </blockquote>
  <p>This is my attempt:</p>
  <pre><code>def check_nil(array1)
    p = Proc.new {|x| x.nil?}
    res= p.call(array1)
    if res == true
      return &quot;true&quot;  
    else  
      return &quot;false&quot;  
    end 
  end
     
  array1 = [{},nil,[]]
  result = check_nil(array1)
  puts &quot;#{result}&quot;
  </code></pre>
  <p>Here actually, the output should be &quot;true&quot; but this code gives &quot;false&quot; as output. Can someone explain the reason?</p>