I'm sure it does, but I can write the same class in C# just as easily:
class Person
{
public int Sanity { get; set; }
public Person()
{
Sanity = 50;
}
}
And to call it:
var programmer = new Person();
programmer.Sanity += 1000000;
Console.WriteLine(programmer.Sanity);
I don't see much difference between Person.new and new Person();.
What are the real ways in which it will knock my socks off? I'm honestly asking. Even though I program C# at work, I'm very interested in the advantages of other languages.
Ruby really is a great language. The author just posted a poor example that is frankly NOT idiomatic Ruby. The proper way to create a getter and setter method on an instance variable is like so:
class Person
attr_accessor :sanity
def initialize
@sanity = 50
end
end
I'm sure it does, but I can write the same class in C# just as easily:
And to call it:I don't see much difference between Person.new and new Person();.What are the real ways in which it will knock my socks off?
I'm honestly asking. Even though I program C# at work, I'm very interested in the advantages of other languages.
Ruby really is a great language. The author just posted a poor example that is frankly NOT idiomatic Ruby. The proper way to create a getter and setter method on an instance variable is like so: