不忍写下去。。。

enum LazyValue{    case NotComputed(()->T)    case Computed(T)}class LazyClass{    private var  _value : LazyValueinit(computation:()->T){

self._value = .NotComputed(computation)

}

//get Method

var value : T {

switch self._value {

case .NotComputed(let temp):

let result = temp();

self._value = .Computed(result)

return result

case .Computed(let temp):

return temp;

}

}

}

你可能感兴趣的:(不忍写下去。。。)