https://github.com/isaced/swiftrubystyle
Write Ruby style code in Swift.
https://github.com/isaced/swiftrubystyle
ruby-syntax swift-extension
Last synced: about 1 year ago
JSON representation
Write Ruby style code in Swift.
- Host: GitHub
- URL: https://github.com/isaced/swiftrubystyle
- Owner: isaced
- License: mit
- Created: 2019-01-15T12:12:51.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-01-16T02:27:48.000Z (over 7 years ago)
- Last Synced: 2025-01-23T00:29:39.538Z (over 1 year ago)
- Topics: ruby-syntax, swift-extension
- Language: Swift
- Size: 6.84 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SwiftRubyStyle
Write Ruby style code in Swift.
## puts
```swift
puts("hello") // hello
```
## times
```swift
3.times {
puts("hi")
}
// hi
// hi
// hi
// or
5.times { i in
puts(i)
}
// 0
// 1
// 2
// 3
// 4
```
## String
```swift
// count
["a"].count // 1
["a","b"].size // 2
["a","b","c"].length // 3
// append
"hello " << "world" // hello world
// *
"a " * 3 // a a a
```
## Array
```swift
// Hello
// Swift
// Ruby
// *n
["a"] * 3 // a a a
["A", "B"] + ["C"] // A B C
```
## Dictionary
```swift
// each
_ = ["A": "Hello A", "B": "Hello B"].each { (k, v) in
puts(k)
puts(v)
}
```