• ###### sunboshancommented on "The 'if' function" elixir solution

In Elixir, `""` and `0` are considered truthy values.

• ###### sunboshancommented on "Short Long Short" elixir solution

Is this idiomatic Elixir way?

• ###### sunboshancommented on "makeAcronym" ruby solution

Learned something new on the `gsub` block method!

• ###### sunboshancommented on "Alternate Square Sum" ruby solution

`sum += value` is not needed, `sum + value` is enough, since the value will be returned to `sum` in each iteration

• ###### sunboshancommented on "Scrabble Score" ruby solution

Doesn't need `+=`, `s + \$dict[ch]` would be enough. :)

• ###### sunboshancommented on "Green Glass Door" ruby solution

Can someone explain this one?

Nice one!

• ###### sunboshancommented on "Insert dashes" ruby solution

Same as num.to_s.gsub(/([13579])(?=[13579])/, '\1-')

• ###### sunboshancommented on "Sum of all arguments" ruby solution

No reason. They are the same.

• ###### sunboshancommented on "Name Array Capping" ruby solution

Here's the bench mark for both methods.

``````require "benchmark"

n = 1_000_000
ARR = %w(today is a good day isn't it?)
Benchmark.bmbm do |bm|
bm.report { n.times { ARR.map(&:capitalize) } }
bm.report { n.times { ARR.map { |i| i.capitalize } } }
end
``````
``````Rehearsal ------------------------------------
1.890000   0.000000   1.890000 (  1.893212)
1.930000   0.010000   1.940000 (  1.928549)
--------------------------- total: 3.830000sec

user     system      total        real
1.900000   0.000000   1.900000 (  1.910439)
2.050000   0.000000   2.050000 (  2.050394)
``````
• ###### sunboshancommented on "Simple Maths Test" ruby solution

Which version of Ruby do you have locally? My Ruby 2.0.0 return `false` for negative numbers.

• ###### sunboshancommented on "A for Apple" kata

Didn't see your JS translation show up?

• ###### sunboshancommented on "Summing a number's digits" ruby solution

`map(&:to_i)` is same as `map(& :to_i)` is same as `map { |x| x.to_i }`.

It's just passing a symbol `:to_i` to the `map` function as a parameter, `&` translate it into a proc.

• ###### sunboshancommented on "Collatz Conjecture Length" ruby solution

It's using a recursive function. It passes two arguments, `n` and `a`, and `a` has a default value `[]`.

In Ruby, `collatz n, a = []` is same as `collatz(n, a = [])`, the parentesis can be omitted.

• ###### sunboshancommented on "Sum up the random string" kata

Try to debug in your local ide to see if it works. If it does work then might be some codewars issue.