filmov
tv
Try method in Ruby on Rails
Показать описание
In Rails, have you ever have to check whether a variable's value was nil before trying to call a method on it?
For example:
end
There's actually a much cooler way to achieve the same result using the try method:
In fact, you could even pass a block to the try method, and that block will only be executed if the object you're calling try on is not nil, like:
💻 Follow for more programming videos 💻
#ruby #programming #computerscience #webdevelopment #softwareengineer #rubyonrails #rubydeveloper #rubyonrailsdeveloper
For example:
end
There's actually a much cooler way to achieve the same result using the try method:
In fact, you could even pass a block to the try method, and that block will only be executed if the object you're calling try on is not nil, like:
💻 Follow for more programming videos 💻
#ruby #programming #computerscience #webdevelopment #softwareengineer #rubyonrails #rubydeveloper #rubyonrailsdeveloper