-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
and
/ or
keywords with raise
/ fail
#415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I find the |
In Perl. :-) Seriously, though - yeah, it's popular to some extent but way more people use modifier |
Sure, i guess that is fine. def current_user
fail 'Authentication failed' unless @current_user ||= authenticate
@current_user # need to return explicitly
end
def current_user
@current_user ||= authenticate or fail 'Authentication failed'
end |
👍 for allowing |
I think the real crux of the issue is that Then again though, |
Pretty sure those were never intended as flow of control operators. This is something which people came up with to justify their existence. It's pretty clear they were actually added to facilitate a style of programming with less parentheses in it, which is a good or a bad thing, depending who you ask. |
Avdi Grimm has a really great (and free) RubyTapas episode about this: http://devblog.avdi.org/2014/08/26/how-to-use-rubys-english-andor-operators-without-going-nuts/ 👍 on use as flow control operators! |
Duplicate of #730 |
The idea of banning the
and
&or
keywords is really cool.However, there is one specific case in which they may be preferred:
Of course, we we could just use
... but doesn't it degrade readability?
Is the usage of
and
oror
, immediately followed by araise
orfail
, justified?I would be happy if you could share your thoughts!
The text was updated successfully, but these errors were encountered: