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
| extension String.StringInterpolation { | |
| mutating func appendInterpolation(_ values: [String], empty defaultValue: @autoclosure () -> String) { | |
| if values.count == 0 { | |
| appendLiteral(defaultValue()) | |
| } else { | |
| appendLiteral(values.joined(separator: ", ")) | |
| } | |
| } | |
| } | |
| func EmptyMsg () -> String { |
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
| extension String.StringInterpolation { | |
| mutating func appendInterpolation(repeat str: String, _ count: Int) { | |
| for _ in 0 ..< count { | |
| appendLiteral(str) | |
| } | |
| } | |
| } | |
| print("\(repeat: "Do what you like\n ", 6)") |
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 Foundation | |
| extension String.StringInterpolation { | |
| mutating func appendInterpolation(_ number: Int, style: NumberFormatter.Style) { | |
| let formatter = NumberFormatter() | |
| formatter.numberStyle = style | |
| if let result = formatter.string(from: number as NSNumber) { | |
| appendLiteral(result) |
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
| class User { | |
| var firstName: String | |
| var lastName: String | |
| init (firstName: String,lastName: String){ | |
| self.firstName = firstName | |
| self.lastName = lastName | |
| } | |
| } | |
| //StringInterpolation 1 |
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
| class Point { | |
| let x: Int, y: Int | |
| init( x: Int, y: Int){ | |
| self.x = x | |
| self.y = y | |
| } | |
| } | |
| let p = Point(x: 21, y: 30) | |
| print(p) |
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
| class Point { | |
| let x: Int, y: Int | |
| init( x: Int, y: Int){ | |
| self.x = x | |
| self.y = y | |
| } | |
| } | |
| let p = Point(x: 21, y: 30) | |
| print(p) |
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
| struct AppUser{ | |
| var firstName: String | |
| var lastName: String | |
| } | |
| let appUser = AppUser(firstName : "Payal", lastName : "Maniyar") | |
| print("User details: \(appUser)") | |
| Output : |
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
| //: Playground - noun: a place where people can play | |
| import UIKit | |
| import UserNotifications | |
| var str = "Hello, playground" | |
| var calendar = Calendar.current | |
| calendar.timeZone = TimeZone.current | |
| var dateFormat = DateFormatter() | |
| dateFormat.dateFormat = "dd MMM yyyy" |
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
| // | |
| // MessageFilterExtension.swift | |
| // SMS Filter Demo | |
| // | |
| // Created by Dhanashree Inc on 11/05/18. | |
| // Copyright © 2018 Dhanashree Inc. All rights reserved. | |
| // | |
| import IdentityLookup |
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
| //: Playground - noun: a place where people can play | |
| import UIKit | |
| struct Photo: Codable | |
| { | |
| //String, URL, Bool and Date conform to Codable. | |
| var title: String | |
| var url: URL | |
| var isSample: Bool | |