-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.swift
40 lines (32 loc) · 958 Bytes
/
example.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import Foundation
import Glibc
// Swift example
func swift_example() {
print("\n// Swift example //")
let myVar = "Cleveland"
print("Hello \(myVar)!")
let oneFiveTenArray = [1, 5, 10]
let timesTwoClosure = {$0 * 2}
let newArray = oneFiveTenArray.map(timesTwoClosure)
print("\(oneFiveTenArray) * 2 => \(newArray)")
}
// Objective-C Foundation Framework example
func objc_example() {
print("\n// Obj-C Foundation Framework example //")
let date = Date()
let dateFormatter = DateFormatter()
dateFormatter.locale = Locale(identifier: "fi_FI")
dateFormatter.dateStyle = .full
let localizedDate = dateFormatter.string(from: date)
print("Localized date: \(localizedDate)")
}
// GNU C Library example
func glibc_example() {
print("\n// GNU C Library example //")
let randNumber = random()
print("Random number: \(randNumber)")
print("")
}
swift_example()
objc_example()
glibc_example()