Ruby | Array min() function
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 :
a = %w[ for geeks]
puts "min() method form : #{a.min()}\n\n"
puts "min() method form : #{a.min(2)}\n\n"
|
Output :
min() method form : for
min() method form : ["for", "geeks"]
Example #2 :
a = %w[hi I can code for geeks]
puts "min() method form : #{a.min(4)}\n\n"
puts "min() method form : #{a.min(1)}\n\n"
|
Output :
min() method form : ["I", "can", "code", "for"]
min() method form : ["I"]
Last Updated :
06 Dec, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...