This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
<script src="https://code.jquery.com/jquery.min.js"></script> | |
<style id="jsbin-css"> | |
body { | |
margin: 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import CoreFoundation | |
//Generic Type Protocol | |
public protocol Stackable { | |
//Generic Type | |
associatedtype E | |
// Push - add new element to stack array | |
mutating func push(_ element: E) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A Protocol that has update function to update Device State | |
protocol State { | |
// function is mutating so that Enum and structure can update the self | |
mutating func update() | |
} | |
// Enum wit Active and Inactive Device state | |
enum DeviceState : State { | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var currencyFormatter = NumberFormatter() | |
currencyFormatter.usesGroupingSeparator = true | |
currencyFormatter.numberStyle = NumberFormatter.Style.currency | |
// localize to your grouping and decimal separator | |
// set locale to Spanish | |
currencyFormatter.locale = Locale(identifier: "eu_ES") | |
var priceString = currencyFormatter.string(from: 12.50) | |
print(priceString) //output : ("12,50 €") | |
// set locale to US |