Firstly, what is an idiom?

According to wikipedia, an idiom is a phrase or a fixed expression that has a figurative, or sometimes literal, meaning. An idiom's figurative meaning is different from the literal meaning.

Instead of writing jargon about it, let me show you how it is used in ruby.

Difference between Non Idiomatic and Idiomatic ruby

How a java developer will write:

for i in 1..5  
  puts i + "Navneet"
end  
def expirationDates  
  currentYear = Date.today.year
  i = 0
  dates = []
  while i <= 20
      dates.push(currentYear + i)
      i += 1
  end
  return dates
end  

Now, code of a Ruby developer with knowledge in idiomatic ruby

5.times do  
  puts i + "Navneet"
end  
def expiration_dates  
  current_year = Date.today.year
  [current_year .. current_year + 20]
end  

Above, examples from talk given at RubyConf 2014 by Craig Buchek

Use of conditional if..then..else

if age == 23  
  #...
elsif name == "navneet"  
  #..
else  
  #..
end  
if age == 23 then  
elsif name == "navneet" then  
else  
  #..
end  

If you have one liner in the conditions use of then will make code look shorter and clear

Use of unless

if !this  
  #..
end  
unless this  
  #..
end  

If checking for negation use unless, and if you are using else block then stick with if else.

Inline function call

unless this  
  call_a_func
end  
call_a_func unless this  

Try avoiding the block if you just have to perform a oneliner i.e funciton call or return, same can be done with if block

Use of try

unless number.nil?  
  number.next
end  
@number.try(:next)

Check not nil

if !name.nil?  
  #..
end  
if name  
  #..
end  

If you have to check not nil, as nil is falsey you can directly check for the true value.

Use of include to check

if age == 23 || age == 43  
  #..
end  
if [23, 43].include?(age)  
  #..
end  

Use of parallel assignment

info = ["Navneet", 23, "foo@bar.com"]  
name  = info[0]  
age   = info[1]  
email = info[2]  
name, age, email = info  

Check for zero

total = 0

if total == 0  
if total.zero?  

Array::sample

to get random values from an array

[1, 2, 3].shuffle.first
[1, 2, 3].sample

Use sample method to find random value from an array.

Use Symbol#to_proc

chars = []  
%w(lion tiger zebra).each do |char|
  chars << char.upcase
end  

Map returns a new array, after performing the operation in the block

%w(lion tiger zebra).map do |char|
  char.upcase
end

%w(lion tiger zebra).map {|char| char.upcase}

%w(lion tiger zebra).map(&:upcase)

As you can see, each iteration of the code becomes more idiomatic.

Use of grep

%w(push bush hush pull).select { |word| word =~ /sh$/ }

%w(push bush hush pull).grep(/sh$/)

If you need to select a word of a particular pattern, use grep.

Memoization

Memoization is an optimization technique used primarily to speed up computer programs by storing the results of expensive function calls and returning the cached result when the same inputs occur again.

In other words, the computation is decreased by storing the result of an expensive function call when you call the same function with the same input parameters the stored "cached" result is used.

In short, it makes program run faster and efficiently.

Simple example:

name = "Navneet"

if name  
  name
else  
  name = "Default"
end  
name = "Navneet"

unless name  
  name = "Default"
end  
name = "Navneet"  
name ||= "Default"  

So, if name is set then 'Navneet' is returned else we get 'Default' as a output. Here we have saved one computer cycle of calculating the name.