Why are C# 3.0 object initializer constructor parentheses optional?

This question was the subject of my blog on September 20th 2010. Josh and Chad’s answers (“they add no value so why require them?” and “to eliminate redundancy”) are basically correct. To flesh that out a bit more: The feature of allowing you to elide the argument list as part of the “larger feature” of … Read more

Why does C# disallow readonly local variables? [closed]

I think it’s a poor judgement on part of C# architects. readonly modifier on local variables helps maintain program correctness (just like asserts) and can potentially help the compiler optimize code (at least in the case of other languages). The fact that it’s disallowed in C# right now, is another argument that some of the … Read more

Why doesn’t Ruby support i++ or i–​ (increment/decrement operators)?

Here is how Matz(Yukihiro Matsumoto) explains it in an old thread: Hi, In message “[ruby-talk:02706] X++?” on 00/05/10, Aleksi Niemelä <aleksi.niemela@cinnober.com> writes: |I got an idea from http://www.pragprog.com:8080/rubyfaq/rubyfaq-5.html#ss5.3 |and thought to try. I didn’t manage to make “auto(in|de)crement” working so |could somebody help here? Does this contain some errors or is the idea |wrong? (1) … Read more

Why does Ruby have both private and protected methods?

protected methods can be called by any instance of the defining class or its subclasses. private methods can be called only from within the calling object. You cannot access another instance’s private methods directly. Here is a quick practical example: def compare_to(x) self.some_method <=> x.some_method end some_method cannot be private here. It must be protected … Read more

Why are private fields private to the type, not the instance?

I think one reason it works this way is because access modifiers work at compile time. As such, determining whether or not a given object is also the current object isn’t easy to do. For example, consider this code: public class Foo { private int bar; public void Baz(Foo other) { other.bar = 2; } … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)