In Swift, I am trying to use the max() and min() functions.
max<T : Comparable>(x: T, y: T, rest: T...) -> T min<T : Comparable>(x: T, y: T, rest: T...) -> T
I am trying to use the max() function in this way:
var paddleX: Int = Int(paddle.position.x) + Int(location.x - previousLocation.x) max(paddleX, paddle.frame.x/2, nil)
but I am getting this error:
Cannot convert the expression's type of '()' to type 'NilType'
Is the nil
causing this problem? What is rest: T...
supposed to be?
The MIN() function returns the smallest value of the selected column. The MAX() function returns the largest value of the selected column.
max() Return Value The max() method returns the maximum element of dictionary . Note: If dictionary is empty, the method returns nil .
Don't pass anything at all there. It's a variadic function, you can call it with two or more parameters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With