I have this code:
def with_else puts 'we enter something funny' if true puts "yes" 'return YES' end 'return what?' else puts 'no' 'return else -> no' end puts with_else
and the conclusion is as follows:
we enter something funny yes no return else -> no
Why can't I get an error? What does def/ else/ mean end?
def
else
end
http://rubyfiddle.com/riddles/8df07
This is actually part of a larger syntax structure:
def foo # method stuff rescue # stuff if an exception is caught else # stuff if no exception is caught ensure # always run after rescue and else end
But each section is optional! Therefore, you can leave rescueand ensureto get your example.
rescue
ensure
Source: https://habr.com/ru/post/1545884/More articles:QLabel fields and populating a profile in shortcuts in Qt - c ++Select specific node output in TOR (with Python code) - pythonHow to open url when clicking on ImageView on Android? - javaRabbitMQ and Node.js how to handle a fail-safe script? - node.jsSecurity Design for iOS App - securityустройства iOS, не получающие многоадресную рассылку UDP, используя GDAsyncUdpSocket - iosPython: Sklearn.linear_model.LinearRegression works weird - pythonExtend all types in Swift? - genericsHow to enable code highlighting in a Visual Studio Performance Analyzer window? - performanceHow to publish the application? - c #All Articles