Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

binary operator % cannot be applied to operands of type UInt32 and int

Tags:

xcode

ios

swift

var Y: Int = 0
Y = arc4random() % 5

I am getting the error

"binary operator % cannot be applied to operands of type UInt32 and int". How can I fix my syntax

like image 800
Dan A Avatar asked Jan 28 '16 18:01

Dan A


1 Answers

Use following

var Y: Int = 0
Y = Int( arc4random() % 5 )
like image 158
Vishnu gondlekar Avatar answered Sep 29 '22 04:09

Vishnu gondlekar