map.rb
api_response = [
{last_name: "Tanaka", first_name: "Taro"},
{last_name: "Taguchi", first_name: "Ichiro"},
{last_name: "Haraguchi", first_name: "Saburo"}
]
full_names = api_response.map {|a| "#{a[:last_name]} #{a[:first_name]}"}
# Returns
# ["Tanaka Taro", "Taguchi Ichiro", "Haraguchi Saburo"]
map.swift
let api_response = [
["last_name": "Tanaka", "first_name": "Taro"],
["last_name": "Taguchi", "first_name": "Ichiro"],
["last_name": "Haraguchi", "first_name": "Saburo"]
]
let full_names = api_response.map {(a) in "\(a['last_name']) \(a['first_name'])"}
# Returns
# ["Tanaka Taro", "Taguchi Ichiro", "Haraguchi Saburo"]
まさに神
エセC言語で痛み付けられた心が洗われますね