Ruby (programming language): Difference between revisions

Content deleted Content added
es:
m reformat code example, it was too wide
Line 33:
Here is a sample of Ruby code:
 
# Execute the following block of code 10 times
<pre>
10.times {
# Execute the following block of code 10 times
# Replace ' ' with ', ' and store in string1
10.times {
string1 = "Hello world".gsub(" ", ",") # Replace ' ' with ', ' and store in string1
 
string1 += "!" # append "!" to variable 'string1'
puts# string1append "!" # printto variable 'string1', followed by a newline
string1 += "!"
}
 
</pre>
# print variable 'string1', followed by a newline
puts string1
}
 
More Ruby code is available in form of sample algorithm implementations in the articles: