Ruby Cheat Sheet
Ex. of Hashes, Array, String, Inegers:


Links


Hashes: A Hash is a dictionary- like collection of unique keys and their values. Also called associative arrays, they are similar to Arrays, but where an Array uses integers as its index a Hash allows you to use any object type.

Hashes enumerate their values in the order that the corresponding keys were inserted.

my_hash={ "F150"=>"car" }

Create a hash

Iterating over hashes


Array: Arrays are ordered, integer-indexed collections of any object.

Array indexing starts at 0. A negative index is assumed to be relative to the end of the array, an index of -1 indicates the last element of the array, -2 is the next to last element in the array, and so on.

To create a array

Add elements to an array

Remove elements from an array


String: A String object holds and manipulates an arbitrary sequence of bytes, typically representing characters.

Strings can store in Ruby using the String object. In addition to providing storage for strings, this object also contains a number of methods, which can be used to manipulate strings

Creating new string


Integers: Integer is the basic for the two concrete classes that hold whole numbers, (Bignum and Fixnum).

Cited sources:

"Fixnum." Class: (Ruby 2.1.2). N.p., n.d. Web. 22 July 2014.

"Bignum." Class: (Ruby 2.1.2). N.p., n.d. Web. 22 July 2014.

"Ruby Strings - Creation and Basics." - Techotopia. N.p., n.d. Web. 22 July 2014.

"Hash." Class: (Ruby 2.1.1). N.p., n.d. Web. 22 July 2014.

"Array." Class: (Ruby 2.1.2). N.p., n.d. Web. 22 July 2014.

"Ruby Strings - Creation and Basics." - Techotopia. N.p., n.d. Web. 22 July 2014.