April 14
Posted by mtoledo
Filed under ruby |
Raganwald has written a very elaborate piece about his “objection to Array#sum“. Since I patircularly like Array#sum, I thought I might weight in on my own blog.
First, I think that his piece has 2 different objections:
1) Array shouldn’t return true for a “responds_to? :sum” call if it has contents that can’t be summed ( like [...]
April 9
Posted by mtoledo
Filed under ruby |
Ruby has a pretty expressive and flexible case statement. It actually differs from most other language’s ’switch’ statements in that it auto-breaks on each condition instead of falling through.
// C
switch (x) {
case 1:
doSomething();
break;
case 2:
doSomethingElse();
break;
}
# ruby
case x
when 1: do_something
when 2: do_something_else
end
I do think not having to break was the right decision, but not everyone agrees and [...]
April 8
Posted by mtoledo
Filed under ruby |
Ruby is a very powerful language, and the methods available to manipulate its 2 main data structures, Array and Hash, are really good. Though, some of them are really obscure, and for some other manipulations you are on your own. This happens specially with the Hash class.
To me, this is probably because although both Array [...]
April 7
Posted by mtoledo
Filed under javascript |
Today I was trying to setup this blog with Syntax Highlighter Plus. Curiously, the syntax highlighting wouldn’t work on the home page where multiple posts are displayed, only when you clicked on a single post.
I’m adding this here because I couldn’t find anything about it anywhere except people suggesting to check the theme’s header and [...]