Get maximum element from array

 Problem

I have an array and want to get the maximum element (highest value).



 Recipe


// Initialize the Array
var a = [1,2,3,4,5]

// Get maximum element

var min = a.maxElement()

print(min!)

				


 Playground