if using "attr_accessor", the variable becomes a C# property. Then we can use it by using "@"

attr_accessor:count# note this statement uses symbol ':count', you can also use a string to define an attribute: attr_accessor'count'# is the same as defcount; @count; enddefcount=(var); @count = var; end# to use it, @count = something.

class(static) variable: @@ (attribute all)

@@count

class(static) method

defself.this_is_a_static_method=(value)#ordefClassName.this_is_a_static_method# The above two are the same because in class definition call, self is set to class.

class

By default, variable inside class are protected

:count is a symbol.
A Ruby symbol is a thing that has both a number (integer) representation and a string representation.

ruby constructor:

def initialize(a, b)
self.a = a
end

how to new:

person = Person.new("a","b")

C# params:

public string Concat(params String[] items)

->
def concat(*items)
result = ""
items.each do |item|
result += item
end
result
end

You see, the arguments for accepts_hash got rolled up into one hash variable. This technique is heavily used in the Ruby On Rails API.
Use Hash to remove arguments order dependency.
The above lines are equivalent to the more verbose ones:

define: jobs = {}
`h = Hash.new(0)` the constructor defines a **default** value for all nonexistent key
jobs["random key"] is nilif no default value is defined, see above line
jobs["developer"] = "Andrew"
jobs = { "developer" => "Andrew" } # the keys are strings, the '=>' is called **hashrocket**
jobs = { :developer => "Andrew", :developer2 => "AZ" } # the keys are symbols
jobs = { developer:"Andrew", developer2:"AZ" } # the keys become symbol! This is the v1.9 feature, see here: http://logicalfriday.com/2011/06/20/i-dont-like-the-ruby-1-9-hash-syntax/
The v1.9 feature makes ruby looks more like other language such as JavaScript.
using symbol: jobs = {} jobs[:Developer] = "Andrew"
the convension is to put extra space at the two end of a hash
jobs.each { |key, value| puts "x"}
fetch method: jobs.fetch(:Developer, "default value")
used inparameter: the parameter accepts a hash, if nothing is passed, it uses the default value {}
defprint_name(params = {})

Set (unordered value with no duplicates, like HashSet in C#)

?? Class inheritance

example:

classEmployeeattr_accessor:first_nameattr_accessor:second_nameendclassManager < Employeedefvacation_days25endend# NOTE this shows duck typing: this class is not even an employee but can be passed to print_daysclassDancerdefvacation_days40endenddefprint_days(employee)
puts "#{employee.vacation_days}"end

class << foo opens foo's singleton class (eigenclass).
class << self opens up self's singleton class, so that methods can be redefined for the current self object (which inside a class or module body is the class or module itself). Usually, this is used to define class/module ("static") methods: