Code, Creativity & Community

Showing posts tagged Ruby Idioms · View all posts

Ruby Blocks Explained: Understanding {|x| x * x} Syntax
Blocks are fundamental to Ruby. The {|x| x * x} syntax defines anonymous functions you pass to methods. Understanding blocks, procs, and lambdas—and when to use each—is central to writing... Read more...
Ruby's Symbol-to-Proc: Understanding .map(&:to_s) Syntax
Ruby's .map(&:to_s) syntax looks cryptic at first. It's syntactic sugar for passing blocks to methods, converting symbols to procs automatically. Understanding it makes Ruby code more concise and idiomatic. Read more...