iluvruby
Execute Code Before and After the Script
over 1 year ago by pogodan on iluvruby.
BEGIN { puts 'This is executed first' } END { puts 'This is executed last' } puts 'Program running...' will output This is executed first Program running...
How to Call Private Methods On Objects
over 1 year ago by pogodan on iluvruby.
Calling private methods can be useful in unit testing to increase the code coverage. send method gives you access to all methods of a particular objectobj...
Avoid Floats
over 1 year ago by pogodan on iluvruby.
Floats are imprecise. 0.4 - 0.3 - 0.1 Instead of 0, the result is quite unexpected: -2.77555756156289e-17. Try it yourself....
Need a Quick Ruby Documentation Lookup
over 1 year ago by pogodan on iluvruby.
Use ri. ri Regexp.match...
Stop Printing Out Values After Each Statement in IRB
over 1 year ago by pogodan on iluvruby.
irb --noecho will do the trick....
Execute Ruby Code Directly from the Command Line
over 1 year ago by pogodan on iluvruby.
ruby -e "puts 'executed inline'" It is the quickest way to execute ruby code....
Check the Syntax of the Ruby Script
over 1 year ago by pogodan on iluvruby.
ruby -c filename.rb will check the syntax without executing the program....
Difference Between Require and Load
over 1 year ago by pogodan on iluvruby.
require if called more than once will not reload the file, while load will. Also load only accepts full filenames....
Appending and Prepending to an Array
over 1 year ago by pogodan on iluvruby.
You are probably familiar with the « operator. When applied to an array the value would get appended to it (ruby arrays preserve order). Forarray...
