home.social

#rubytips — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #rubytips, aggregated by home.social.

  1. Master error handling in Ruby 🛠️
    Our latest guide breaks down try-catch and exception handling with clear examples.
    Read more 👉 railscarma.com/blog/ruby-try-catch-explained-exception-handling-in-ruby/
    #Ruby #ExceptionHandling #RailsCarma #RubyTips

  2. When you use the block syntax with Hash.new to define a default value, you lock yourself to only using the square bracket syntax for value lookup. The fetch method ignores the block, default, and default_proc.

    This bit me hard this week, and my pair, @gd, got to watch me flounder on why fetch wasn’t getting the default value.

    By the way, the Hash.new with a block is great for memoization of calculated or network lookup data.

    #Ruby #RubyTips #RubyGotchas #ThisWeekILearned #TWIL