Once

Once is an object that will perform exactly one action.

  • Returns a new Once.

    Declaration

    Swift

    public init() {}
  • Calls the action if and only if doit is being called for the first time for this instance of Once. In other words, given

    var once Once
    

    If doit is called multiple times, only the first call will invoke action, even if action has a different value in each invocation. A new instance of Once is required for each function to execute.

    This method is intended for initialization that must be run exactly once.

    Declaration

    Swift

    public func doit(action: ()->())