On 3/9/12 6:21 PM, Nick Sabalausky wrote:
"Ary Manzana"<a...@esperanto.org.ar>  wrote in message
news:jjdqe4$1oeb$1...@digitalmars.com...

Indeed, count can be used to count elements:

ruby-1.8.7-p352 :002>  [1, 2, 3, 3, 3].count 3
  =>  3
ruby-1.8.7-p352 :004>  [1, 2, 3, 3, 3].count&:odd?
  =>  4
ruby-1.8.7-p352 :005>  [1, 2, 3, 3, 3].count { |x| x<= 2 }
  =>  2


Interesting idea.


IMAO, this sort of "write your mind and somehow it just works" thing
only encourages lazy programming (guessing what something does without
knowing for sure, and copy-n-pasting code without understanding it,
which leads to bit rot and hideous patchwork code that houses all sorts
of subtle bugs and corner-case failures).

We also write lots of tests in Ruby. :-P

Writing plenty of tests is good no matter what, but it's an inferior
substitute for proper compile-time checks. Not that that's applicable to
this "count vs length vs size" subdiscussion, of course. Just a general
comment on the dynamic world's fairly common "lots of tests" excuse.

True. I'd like to find (or do) a language that combines both of two worlds.

I started one, but I don't have much time to continue it and also I'm stuck with design/implementation decisions. :-P

https://github.com/asterite/crystal

(not everything in the bullet list is implemented, those are just wishes, but everything in "samples" compiles and runs)

And other people had similar ideas:

http://whitequark.org/blog/2011/12/21/statically-compiled-ruby/

Reply via email to