Shell. • There are projects to create a GUI for Ruby (such as Shoes); however, the command line tools continue to dominate. • Ruby Programs can be easily installed using RubyGems. • You can install multiple versions of Ruby on your computer with RVM and rbenv.
for no newline constant. • Actually nobody writes it like this! • Ruby does not require parenthesis for methods • No semicolons after each statement. puts(“Hello World”) print(“Hello World\n”)
addition of newline constant and print for no newline constant. • Actually nobody writes it like this! • Ruby does not require parenthesis for methods • No semicolons after each statement.
you would in Math. • To initialize objects use the new method. • Not normally a good idea to override new; however some projects do. x = 4 today = Time.now
dollar sign ($) implies global accessibility • An ampersand (@) implies an instance variable • 2 ampersands (@@) implies a static class variable me = ‘ben’ # available to this area $you = tu # available to the entire program @age = 17 # available to the instance methods of class @@version = 1 # available statically to the class
cannot be overloaded. • You can de ne optional parameters. • Ruby 2.0 announced named parameters. • Can be overridden in child classes. • May have multiple aliases. • Parenthesis are optional – recommended for some operations • Called on objects using a (.) dot
to provide a list. • To make a parameter optional, specify a value to use if none is speci ed during invocation. • This makes from optional (better than overloading). def go(to, from) end def go(to, from = “here”) end
parameters allow users to specify names for the values, and this cleans up the code. • To call this method, we would write: • Coke is implied because named parameters are optional parameters (this means that the order does not matter)! def eat_dinner(food: “turkey”, drink: “coke”) end eat_dinner food: “spaghetti”