Quantcast
Channel: Master Ruby/Rails Programming
Browsing all 25 articles
Browse latest View live

Anonymous functions

An interesting fact:var sum = function(x,y,z) { return (x+y+z);}(1,2,3);is an anonymous function. That means sub is now 6. If you call sum with any arguments it will bark at you. Where as this:var sum...

View Article


IRB tricks: assign last statement's return value to a var

irb(main):001:0> 1+2=> 3irb(main):002:0> a=_=> 3irb(main):003:0> a=> 3Underscore assigns the last executed statement's return value to a.

View Article


Export MySQL query result to a CSV file

SELECT a,b,a+b INTO OUTFILE '/tmp/result.txt' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' FROM...

View Article

Missing gems even though they are present

Have you seen the following only to realize all those are already installed?Missing these required gems: rspec = 1.3.0 rspec-rails = 1.3.2My environment.rb has entries for both of them like:config.gem...

View Article

Difference between "and" and "&&"

klasses = ['last'] && txt = '' if idx == (tabs.length - 1)At the end of this statement klasses will contain "".klasses = ['last'] and txt = '' if idx == (tabs.length - 1)At the end of this...

View Article

Browsing all 25 articles
Browse latest View live