Ruby code examples
5 short, tested snippets. Pick one to see the code with notes, or search Zest for something specific, such as “ruby read a file”.
- Read a filetext = File.read("data.txt")
- map, select and reducenums = [1, 2, 3, 4]
- Hash iterationh = { "a" => 1, "b" => 2 }
- Define a classclass Dog
- Hello worldputs "Hello, World!"