https://github.com/supermarcus/swiftyemoji
Emoji with Swift...or...Swift with Emojis
https://github.com/supermarcus/swiftyemoji
emojis swift
Last synced: 3 months ago
JSON representation
Emoji with Swift...or...Swift with Emojis
- Host: GitHub
- URL: https://github.com/supermarcus/swiftyemoji
- Owner: SuperMarcus
- License: mit
- Created: 2018-01-27T18:00:50.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-27T18:29:34.000Z (over 8 years ago)
- Last Synced: 2025-03-27T13:02:00.464Z (about 1 year ago)
- Topics: emojis, swift
- Language: Swift
- Homepage:
- Size: 2.93 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Swifty Emoji
============
Add a few lines to your Swift project, start coding with emoji.
## Swift + đđ = Awesome
Everybody loves emoji, and everybody loves swift. Swift is a powerful but serious language,
with emojis, it becomes funnier and cuter than ever.
## Define your types
Before anything ever happens, we define the basic types in swift.
### Bool
```swift
typealias đđ = Bool
//Here we also define 'true' and 'false'
let đ = true
let đ = false
```
### Strings
```swift
typealias đ¤ = String
typealias âšī¸đ¤ = CustomStringConvertible
```
### Numbers
```swift
typealias đĸ = Int
typealias đĸđļ = Double
```
## Convert Built-in Functions
Once we defined some necessary types, we can create some proxy functions like print
```swift
// Here I just used a closure calling the print function
let đ¨ = { (đ: âšī¸đ¤) in print(đ) }
```
## Control Flows
This is the part where you'll have to use your brain. Here is my version of `if-else`
```swift
//First define a struct so we can implement `else`
struct đđ{
var đ: (() -> ()) -> ()
}
//Then we define the 'if' function
func đ(_ đđ: đđ, _ đđ: () -> ()) -> đđ {
//Check if condition is true
if(đđ){
//If true, call the trailing closure
đđ()
//Return đđ with a closure that does nothing
return đđ(đ: { _ in })
} else {
//Return đđ with a closure that calls the parameter immedietly
return đđ(đ: { đ in đ() })
}
}
```
This results in something like:
```swift
đ(đ){ đ¨("yes") }
.đ{ đ¨("no") }
//prints: 'yes'
```