Ruby vs. C#
Suppose you wanted to print the numbers from 1 to 10 in C#. No big deal:
public static class IntExtensions {
public static List<int> UpTo(this int start, int end) {
var range = new List<int>();
for(int i = start; i < end; i++) {
range.Add(i);
}
return range;
}
}
(1).UpTo(10).ForEach(x => Console.WriteLine(x));
So, what does the Ruby look like?
p *1..10
Ahem.
blog comments powered by Disqus
On Code
- 02 May 2009 » On Haml and jQuery
- 02 Apr 2009 » Ruby vs. C#
On Politics
- 21 Apr 2009 » The Obama Mystique
Get in touch!
pius [at] alum [dot] mit [dot] edu

