Reading Time: 1 minutes

Programmers like to take a longer break far away from their daily lives. They can write a code in the comfortable conditions, for example at the sea coast. Changing a location acts as a refresher. It gives them vitality they need to finish writing the code. The location they choose for the vacation are different and depends on the programmer’s personality. While some of them prefer the sea, others choose rocky mountains. Then there are those who prefer crouded cities. Anyway, when you are a ruby developer, it doesn’t matter where you are, you will need the following smart tips for your work:

1. Operator converts any value on type boolean.

for example:

!!nil

=> false
!!0

=> true
foo = Object.new
!!foo

=> true
2. If you pass a block to File.open method, after that you don’t have to concern about the closing the file. The record is as follows:

file = File.open(“file.txt”, “w”)
file.write(“Hello world”)
file.close

is equivalent to:
File.open(“file.txt”, “w”) do |file|
file.write(“Hello world”)
end

3.Checking quickly the file. rb in terms of syntax without executing it:

ruby -c file.rb

Additional information (for example about assigned but not used variables);

ruby -wc file.rb

Your coding vacation will be really awesome! Warm and sunny August brings all good for #SummerSoftware!

Railwaymen August calendar 2014 coding vacations Railwaymen August calendar 2014 coding vacations

Protenders banners-1

Recent Posts