3 ms·
Here's the source of try from active_support def try(*a, &b) if a.empty? && block_given? yield self else public_send(*a, &b) if
by nottombrown 12y ago
Here's the source of try from active_support
def try(*a, &b)
if a.empty? && block_given?
yield self
else
public_send(*a, &b) if respond_to?(a.first)
end
end
https://github.com/rails/rails/blob/d68419a88e424e588c2d8decc69874bd00588766/activesupport/lib/active_support/core_ext/object/try.rb https://github.com/rails/rails/blob/d68419a88e424e588c2d8dec...
Should be easy to do the same in swift. Let me take a stab at it.