Install
openclaw skills install rubyWrite reliable Ruby avoiding mutable string traps, block pitfalls, and metaprogramming bugs.
openclaw skills install ruby| 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 |
s = "hi"; s << "!"; t = s means t also has "!"== vs equal? vs eql? — == value, equal? identity, eql? hash equalityHash.new([]) shares same array, use block formreturn in proc returns from enclosing method — use lambda for local returnx = 1; [2].each { |x| }; x is still 1 (3.0+)method_missing without respond_to_missing? — breaks respond_to? checksprivate 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_literal: true makes strings immutableSymbol#to_proc — &:method_name only works with no-argument methodsrescue => e without type — catches StandardError, not Exceptionensure always runs — even after return, use for cleanup