//
//  AutomaticLazyOptional.swift
//  SignificantSpices
//
//  Created by Jan Nash (resmio) on 08.05.18.
//  Copyright © 2018 resmio. All rights reserved.
//

import Foundation


// MARK: // Public
// MARK: - Custom Operators
postfix operator ¡
postfix operator ¿


// MARK: - AutomaticLazyOptional
// MARK: Convenience Typealias
public typealias ALO = AutomaticLazyOptional


// MARK: Interface
public extension AutomaticLazyOptional {
    mutating func clear() {
        self._value = nil
    }
}


// MARK: Struct Declaration
public struct AutomaticLazyOptional<T> {
    public init(_ createValue: @escaping () -> T) {
        self._createValue = createValue
    }
    
    private var _createValue: () -> T
    private var _value: T?
}


// MARK: // Private
// MARK: Get Implementation
private extension AutomaticLazyOptional {
    mutating func _get() -> T {
        guard let value: T = self._value else {
            let value: T = self._createValue()
            self._value = value
            return value
        }
        return value
    }
}

//
//  AutomaticLazyOptional.swift
//  SignificantSpices
//
//  Created by Jan Nash (resmio) on 08.05.18.
//  Copyright © 2018 resmio. All rights reserved.
//

import Foundation


// MARK: // Public
// MARK: - Custom Operators
postfix operator ¡
postfix operator ¿


// MARK: - AutomaticLazyOptional
// MARK: Convenience Typealias
public typealias ALO = AutomaticLazyOptional


// MARK: Interface
public extension AutomaticLazyOptional {
    public mutating func clear() {
        self._value = nil
    }
}


// MARK: Struct Declaration
public struct AutomaticLazyOptional<T> {
    public init(_ createValue: @escaping () -> T) {
        self._createValue = createValue
    }
    
    private var _createValue: () -> T
    private var _value: T?
}


// MARK: // Private
// MARK: Get Implementation
private extension AutomaticLazyOptional {
    mutating func _get() -> T {
        guard let value: T = self._value else {
            let value: T = self._createValue()
            self._value = value
            return value
        }
        return value
    }
}

Correct access level for clear function
Correct access level for clear function
