Skip to content

Instantly share code, notes, and snippets.

Last active Aug 29, 2015
What would you like to do?
Swift and Ruby comparison
cities = ["London", "San Francisco", "Tokyo", "Barcelona", "Sydney"]
sorted_cities = cities.sort
if sorted_cities.include?("London")
puts "London is city number #{sorted_cities.index('London')} in the list"
let cities = ["London", "San Francisco", "Tokyo", "Barcelona", "Sydney"]
let sortedCities = sort(cities) { $0 < $1 }
if let indexOfLondon = find(sortedCities, "London") {
println("London is city number \(indexOfLondon + 1) in the list")
def configure_labels(labels: [])
label_text_color = UIColor.green_color
labels.each do |label|
# label inferred to be UILabel
label.text_color = label_text_color
func configureLabels(labels: UILabel[]) {
let labelTextColor = UIColor.greenColor()
for label in labels {
// label inferred to be UILabel
label.textColor = labelTextColor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment