22 Mar '14, 8pm

Explains how to write #Ruby Driver Test code to enforce the number of Req'd Method arguments

Is there a way to return the number of required arguments, the number of optional arguments and whether or not a splat is present for a method? The closest I've managed to find is Method.arity which will return a number which indicates the number of required arguments and the *presence* of optional arguments only (but in a non-obvious way): With only required arguments, it behaves as expected: >> def foo(a, b); end => nil >> method(:foo).arity => 2 When optional arguments are introduced however: >> def foo(a, b=2); end => nil >> method(:foo).arity => -2 Documentation reveals that when a method has optional arguments, the arity is -n - 1 where n is the number of required arguments (which seems a little arbitrary, is there a historical reason for this?). However, adding new optional arguments and splats makes no difference to the arity: >> def foo(a, b=2, *c); end => nil >> ...

Full article: https://www.ruby-forum.com/topic/147614

Tweets

If you wanna learn #ruby, coming from #java

ruby-lang.org 22 Mar '14, 3pm

Java está maduro. Está probado. Y es rápido (contrariamente a lo que todavía afirman las masas anti-java). También es bast...

[ruby-trunk - Feature #8119][Open] more efficie...

ruby-forum.com 21 Mar '14, 10pm

Issue #8119 has been reported by vjoel (Joel VanderWerf). ---------------------------------------- Feature #8119: more eff...

Harvard Scientists Propose Method to Capture The Energy Released by Earth's Surface

Harvard Scientists Propose Method to Capture Th...

greenoptimistic.com 21 Mar '14, 8pm

When it comes to renewable energy , the Sun seems to be one of the most obvious sources, and this is why a lot of research...

A simple way to know if you are dehydrated.

runnersworld.com 30 Mar '14, 1pm

No one doubts that proper hydration is necessary for optimal functioning. But a debate has raged in recent years about how...

@megonwheels I'm hoping we can get good & easy ...

rubydoc.info 01 Apr '14, 10pm

Use this to return the rounding mode. You may also pass a rounding mode and a block to temporatly change it. It will then ...