ruby - Why is a `catch` block called if there is no `throw`? -
the following:
catch :something   print true end   will print true console. thought point of catch was called corresponding throw.
less importantly, there 1 liner syntax? surprised catch :something { print true } raises syntaxerror.
why
catchblock called if there nothrow?perhaps there
throwbefore, , programmer forgot deletecatchwhenthrowdeleted, or doesn't know how usecatch.but more in case failed ask "why catch block executed if there no
throw?" answer questioncatchblock executed pointthrowraised. ifthrownot raised,catchblock executed.is there 1 liner syntax?
yes. don't omit parentheses.
catch(:something){print true}
Comments
Post a Comment