IIFE (Instant Call Function Expression) is a very commonly used template in JavaScript. Swift also looks like supproting. Like this:
let one = { 1 }
and the explicit type declaration and persistent write function works well.
let one:Int = { $0 }(1)
/// one: Int
but the constant-returnd function cannot be deduced by its own type.
let one = { $0 }(1)
and I force this shell to run.
//inferred.swift
var i:Int = 0
let id = { $0 }(i)
println(id)
Whemphasized textile silgen closexprpr SIL @ _TF8inferredU_FRSiSi function for expression in [./inferred.swift:4:10 - line: 4: 15] RangeText = "{$ 0}" [1] 29364 segmentation error. /inferred.swift
Is there something I missed or did I have the wrong styntax?
source
share