Ruby basics [2d]
Ruby is the programming language we use almost exclusively.
- Be able to read and write simple Ruby programs.
- Gain an understanding of the following concepts:
- Basic datatypes: Strings, Numbers, Booleans, Arrays, Hashes
- Basic language constructs:
- Regular expressions
- Errors and
- Object orientation
- Class methods vs instance methods (
- Modules and
- Code blocks
- Input and Output
- Know where to find documentation for Ruby's standard library.
Look at these
- Learn Ruby the Hard Way: Extremely detailed tutorial starting from the very, very basics. Skip this if you have programmed before.
- Ruby from other languages: Outlines the differences if you're coming from C/C++, Java, Perl, PHP or Python
- codeacademy.com: Longer tutorial
- Understanding Scope in Ruby: Article about variable visibility in ruby programs. The first part are important basics, the second part are special cases (quite advanced)
- RubyMonk: Ruby Primer: Great examples for many common Ruby idioms
- Pragmatic Programmer's Guide: Complete book on ruby (chapters upt to "Basic Input and Output")
- regexone.com: Tutorial for regular expressions
- exercism.io: Solve practice problems in over 30 different languages (currently 91 Ruby problems)
- apidock.com: Reference for Ruby standard libraries
- devdocs.io: DevDocs combines multiple API documentations in a fast, organized, and searchable interface
Write a small ruby programm
cw that accepts a filename, counts the number of
words, lines and paragraphs, and outputs the result.
- Find out about
- Look up
- Learn about regular expressions.
Array a new method
.random_each, that loops randomly through the entries.
I want to be able to say
[1, 2, 3, 4, 5].random_each do |value| puts value end
4 2 1 5 3
- Find out about "class reopening" aka. "monkey patching" (e.g. http://runtime-era.blogspot.com/2012/12/reopen-and-modify-ruby-classes-monkey.html)
- Find out about