How can I deal with an error of a line about Swift code in WWDC 2014 -


i followed wwdc 2014 session 403 write code in playground file:

var onchange:(int)->void = {}      

but got error: 'int' not subtype of '{}' , why? line same 1 in video.

the entire code is:

class temperaturenotifier {      var onchange:(int)->void = {}       var currenttemp = 72       init() {           onchange = { temp in                self.currenttemp = temp            }      } } 

anyone knows reason?

at least current version of swift have access to, i've found if have arguments in closure, kind of error pops up. in order fix it, have give close in syntax:

class temperaturenotifier {     var onchange : (int) -> void = {x in}     var currenttemp = 72      init() {         self.onchange = { temp in             self.currenttemp = temp         }     } } 

it seems silly - since got code session video - bug in swift. should file bug report @ http://bugreport.apple.com.


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -