Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/muratcakmak/swift-vs-ruby
Comparison of Swift and Ruby
https://github.com/muratcakmak/swift-vs-ruby
comparison rubyists swift
Last synced: 5 days ago
JSON representation
Comparison of Swift and Ruby
- Host: GitHub
- URL: https://github.com/muratcakmak/swift-vs-ruby
- Owner: muratcakmak
- Created: 2017-09-18T04:40:35.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-11-10T18:52:52.000Z (about 7 years ago)
- Last Synced: 2024-12-15T18:55:16.885Z (7 days ago)
- Topics: comparison, rubyists, swift
- Homepage:
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Swift-vs-Ruby
## Comments
Both languages support one-line and multi-line comments
```
# Ruby=begin
multi-line
code comment
=end// Swift
/*
multi-line
code comment
*/
```## Constant and Variable declaration
Ruby doesn't have constant. Swift does.```
# Rubylegal_age = 18
// Swift
let legalAge = 18 //This is a constant
var currentAge = 27 //This is variable
```## String Interpolation
```
# Rubyname = "Oguzhan"
puts "Hello, #{name}."// Swift
let name = "Oguzhan"
print("Hello, \(name)")
```## Type Inference
Ruby is a dynamic type language. A variable can store anything: integers, strings, floats, objects.
Swift is a type safe language. Compiler yells at your code, if you try to reassing an integer to string variable. However, Swift has a type inference.
```
# Ruby
name = "Oguzhan"
name = 89.00// Swift
var name = "Oguzhan"
name = 89.00 // Compiler Error!```
## Further Readings
* [An introduction to Swift for Ruby Developers](http://www.aidanf.net/posts/an-introduction-to-swift-for-ruby-developers)
* [Swift for Rubyists](https://academy.realm.io/posts/swift-for-rubyists/)
* [5 Reasons Why Rubyist Will Love Swift](https://littlelines.com/blog/2014/06/11/why-rubyist-will-love-swift)