Michał Zdunek
$ irb
>> def get_error type = :none
>> if type == :none
>> "No error"
>> elsif type == :memory
>> "Memory error"
>> else
>> "Other error"
>> end
>> end
>> get_error
=> "No error"
>> get_error :memory
=> "Memory error"
>> capitals = {:poland => "Warsaw", :russia => "St Petersburg"}
=> {:poland=>"Warsaw", :russia=>"St Petersburg"}
>> capitals["poland"] = "Warszawa"
=> "Warszawa"
>> capitals[:russia] = "Moscow"
=> "Moscow"
>> capitals
=> {:poland=>"Warsaw", :russia=>"Moscow", "poland"=>"Warszawa"}
>> capitals[:russia]
=> "Moscow"
>> [1, 2].each {|n| puts n}
1
2
>> [1, 2].each do |n|
>> puts n
>> end
1
2
>> [1, 2].map {|n| n + 2}
=> [3, 4]
class Example
def initialize id
@id = id
end
def self.get_id
0
end
def get_id
@id
end
end
>> example = Example.new 2
=> #<Example:0x0000000250f580 @id=2>
>> example.get_id
=> 2
>> Example.get_id
=> 0
$ gem install rails
#content
.left.column
%p= print_information
.right.column
- if sidebar
Site sidebar
<div id="content">
<div class="left column">
<p><%= print_information %></p>
</div>
<div class="right column">
<% if sidebar %>
Site sidebar
<% end %>
</div>
</div>