News for hackers. Stuff that matters.
Re:Method Arguments In Ruby by _giu on Tuesday August 18, 2009 @05:42AM (#770100)
Java has the same types of method arguments.

C# (.NET 3.5) misses one type of method argument: the default parameter (it will be shipped with .NET 4.0). I have to admit, it happened only once that I missed default parameters in C#. however, there's a workaround to solve this problem: http://msdn.microsoft.com/en-us/library/aa287762(VS.71).aspx

Re:Method Arguments In Ruby by bad_user on Tuesday August 18, 2009 @08:24AM (#770279)
> it happened only once that I missed default parameters in C#

I actually missed it lots of times. You can work around it by overloading the method, but that's boilerplate for a simple concept.

I also miss named arguments (in both Ruby and C#). When reading the code, when a method has more arguments than one I often forget what the arguments are or their positioning, and it is a lot more readable to specify the arguments by their names ...

   lockfile( path = '/var/run/script', timeout = 60, on_timeout = handler)
Ruby doesn't support that. It only has syntactic sugar for the case in which the argument of the method is a hash, but then the method definition becomes less clear.
Re:Method Arguments In Ruby by _giu on Tuesday August 18, 2009 @11:39AM (#770661)
I totally agree with you! the code is definitely more readable. I think the object initalizer (e.g. var o = new MyObject(){ID=123};) was a step in the direction of named parameters.

however, it looks like named parameters will be shipped with .NET 4.0: http://geekswithblogs.net/michelotti/archive/2009/01/22/c-4....

Re:Method Arguments In Ruby by nudded on Tuesday August 18, 2009 @06:45AM (#770164)
> Java has the same types of method arguments.

no it hasn't. You can't do

   public method(String name = "test") {...}
in Java
Re:Method Arguments In Ruby by _giu on Tuesday August 18, 2009 @07:10AM (#770187)
I completely forgot about that (long time no intensive Java programming for me)! thanks for the correction