DEV Community

Andrew ⚛️ & ☕
Andrew ⚛️ & ☕

Posted on

Find the smallest integer in the array with Ruby

Top comments (4)

Collapse
 
salex profile image
Steve Alex

Whats wrong with

a = [-1,1,4,5,6,9]

irb(main):005:0> a.min
=> -1

Collapse
 
andrew_losseff profile image
Andrew ⚛️ & ☕ • Edited

Hi Steve!

In solution #2 I use a.min

def find_smallest_int(arr)
  arr.min
end

And in my opinion, this is the best one.

You can see all of my solutions here: losseff.xyz/katas/008-find-the-sma...

Collapse
 
salex profile image
Steve Alex

Sorry, I didn't see that one - screen too small. I just heard a couple loop solutions.

Thread Thread
 
andrew_losseff profile image
Andrew ⚛️ & ☕

👍
Thanks for the feedback!
I'll use bigger font size and will give more info about all approaches before writing the code.