ruby

star 8

Write reliable Ruby avoiding mutable string traps, block pitfalls, and metaprogramming bugs.

modbender By modbender schedule Updated 3/6/2026

name: Ruby slug: ruby version: 1.0.1 description: Write reliable Ruby avoiding mutable string traps, block pitfalls, and metaprogramming bugs. metadata: {"clawdbot":{"emoji":"๐Ÿ’Ž","requires":{"bins":["ruby"]},"os":["linux","darwin","win32"]}}

Quick Reference

Topic File
Mutable strings, object equality objects.md
Proc vs lambda, return behavior blocks.md
Visibility, method_missing methods.md
Array/hash mutation traps collections.md
define_method, eval traps metaprogramming.md
ActiveRecord, N+1, callbacks rails.md

Critical Rules

  • Strings are mutable โ€” s = "hi"; s << "!"; t = s means t also has "!"
  • == vs equal? vs eql? โ€” == value, equal? identity, eql? hash equality
  • Default hash value is shared โ€” Hash.new([]) shares same array, use block form
  • return in proc returns from enclosing method โ€” use lambda for local return
  • Block variable shadows outer scope โ€” x = 1; [2].each { |x| }; x is still 1 (3.0+)
  • method_missing without respond_to_missing? โ€” breaks respond_to? checks
  • private in Ruby is per-object โ€” self.private_method fails, implicit receiver works
  • ||= doesn't work for false/nil distinction โ€” false ||= true replaces false
  • Frozen string literals โ€” # frozen_string_literal: true makes strings immutable
  • Symbol#to_proc โ€” &:method_name only works with no-argument methods
  • rescue => e without type โ€” catches StandardError, not Exception
  • ensure always runs โ€” even after return, use for cleanup
Install via CLI
npx skills add https://github.com/modbender/skill-library-mcp --skill ruby
Repository Details
star Stars 8
call_split Forks 2
navigation Branch main
article Path SKILL.md
More from Creator