CSC/ECE 517 Fall 2012/ch1b 1w54 go

From Expertiza_Wiki
Revision as of 00:13, 3 October 2012 by Jtcole2 (talk | contribs)
Jump to navigation Jump to search

SaaS Ruby 101

Introduction

The Coursera video series were created to give free college level lessons to anyone with internet access. The Saas video discussed in this wiki page is the Ruby 101 provided by California University. The video covers the fundamentals of the Ruby language and the basic concepts needed to write programs. More information about the language can be found at its Wikipedia page.

What is Ruby

The Ruby language is an interpreted language and a scripting language, meaning that there is no compile time as in other OO languages. Without the compile time, Ruby programs lose many warnings that programmers rely on for safety.

Ruby is also a dynamically typed language meaning that the type of some things may not be determinable until run time. All objects have types but variables that reference those objects do not have to have types stated explicitly.


Syntax

Differences between Ruby and other OO languages (syntactic sugar)

What ends a statement (; and new line, talk about line breaks)


Objects

Ruby is an OO language but unlike other such languages everything in Ruby is an object. Anything created in Ruby can have messages passed to it or be referenced like an object at any time; whether or not this will do anything is determined by what is referenced.


Variables

Strings in Ruby are treated very similarly to how they are treated in Java. You can find their length, concatenate them, find sub-strings, and use regex expressions on them as well. Most of these features, save the last, are built right in to the string data type used.

Symbols are special types in Ruby. Essentially they are immutable strings (they cannot be changed) and their value is just themselves. They begin with a colon and then a lowercase name, (e.g. :symbol is a symbol). Although symbols are a special type of string, they are not actually strings. A symbol and a string with the same name will not be equal to one another. Symbols are used to denote something as being special, it specifies that the name used is not arbitrary and is one of a fixed set.

-Arrays

Hashes, also known as dictionaries, are like arrays that have key->value pairs as their entries. The values for each key does not have to be the same type as the key that references it.


Methods

References

http://tryruby.org/ - A helpful site that provides an interface to execute your ruby code

http://en.wikibooks.org/wiki/Ruby_By_Examples - Wiki book that discusses Ruby and its' syntax

http://rubyinstaller.org/ - Link to download Ruby

http://en.wikipedia.org/wiki/Ruby_(programming_language)- Wikipedia page