Why does
[].all?{|a| a.include?('_')}
return true?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Your code asks about the truth of the following statement: “For all elements
ain the empty list,aincludes the character'_'.” Because there are no elements in the empty list, the statement is true. (This is referred to as vacuous truth in logic.) It might be easier to understand if you instead try to find a way to make that expression false. This would require having at least one element in the empty list which did not contain'_'. However, the empty list is empty, so no such element can exist. Therefore, the statement can’t meaningfully be false, so it must be true.