In IF block i need to check if some condition true and if it does, exit from block.
#something like this
if 1 == 1
return if some_object && some_object.property
puts 'hello'
end
How can i do it?
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.
You can’t break out of an
iflike that. What you can do is add a sub-clause to it:If you’re having problems with your logic being too nested and you need a way to flatten it out better, maybe what you want to do is compute a variable before hand and then only dive in if you need to:
There’s a number of ways to avoid having a deeply nested structure without having to
breakit.