Related Articles

Related Articles

Ruby | Array min() function
  • Last Updated : 06 Dec, 2019

Array#min() : min() is a Array class method which returns the minimum value in this array.

Syntax: Array.min()

Parameter: Array

Return: the minimum value in this array.

Example #1 :



filter_none

edit
close

play_arrow

link
brightness_4
code

# Ruby code for min() method
  
# declaring array
a = %w[for geeks]
  
  
# min method example
puts "min() method form : #{a.min()}\n\n"
  
puts "min() method form : #{a.min(2)}\n\n"

chevron_right


Output :

min() method form : for

min() method form : ["for", "geeks"]

Example #2 :

filter_none

edit
close

play_arrow

link
brightness_4
code

# Ruby code for min() method
  
# declaring array
a = %w[hi I can code for geeks]
  
  
# min method example
puts "min() method form : #{a.min(4)}\n\n"
  
puts "min() method form : #{a.min(1)}\n\n"

chevron_right


Output :

min() method form : ["I", "can", "code", "for"]

min() method form : ["I"]
My Personal Notes arrow_drop_up
Recommended Articles
Page :