I would like to know how Rails handles the method blank?.
I was trying to build my own blank? equivalent method but it’s not easy. Here’s my try:
def my_blank(state)
if state == nil or state.empty? == true
true
else
false
end
end
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.
This project is open source, so just take a look at the source: https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/object/blank.rb
You’ll see that there are individual methods written for the various classes (like
String,Array, etc.)