Ruby-Syntax


Symbols and Strings
:Symbol
"String"
name = "Roger"
"My Name is #{name}"


Instance variable
@instance_variable


Arrays
my_array = ['one ' , 'two', 'three']
my_array[0]
my_array.first


Hash table
my_hash = {:fish => "Salmon"}
my_hash[:fish]


Block
my_array.each do |an_element|
puts an_element
end


my_array.each_with_index do |an_element, index|
puts "#{an_element} is number #{index}"
end


Class
class RedCar < Car

end



Ruby specific tags in HTML templates
<%# Comment -%>
<%= link_to "Google", "http://google.com" -%>

<%= my_array.each_with_index do |an_element, index| -%>
<%= puts an_element -%>
<%= end -%>




Siehe auch

There are no comments on this page. [Add comment]

Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki