标签云

微信群

扫码加入我们

WeChat QR Code

I have two arrays.The first is a set of keys:[476126287, 373653306, 294631223, 14179684, 257968797, 124332158, 315977804, 416828937, 406598349, 397492006, 36353099, 395888209, 13870552, 381624315, 14216932, 40042684, 346236824, 222538115, 256661100, 89384897, 26294306, 264885135, 259371103, 246437428, 21024561, 215167635, 201236316, 178544572, 15290498, 23330844, 90943456, 103080311, 31276046, 18377430, 48403129, 18435047, 89850690]The second is a set is a large (dictionary) of key-value pairs.[[476126287, "BURANE"], [373653306, "PENAHI"], [294631223, "CIWUCU"], [14179684, "TOHAPU"], [257968797, "SUZEJU"], [124332158, "DUPAKE"], [315977804, "MIZEJU"], [416828937, "ZOPIHA"], [406598349, "YAYOJI"], [397492006, "CISOCI"], [36353099, "TAWIHU"], [395888209, "SUCOVE"], [13870552, "TACIYA"], [40042684, "WEBUWA"], [346236824, "WOPESI"], [222538115, "KECUGA"], [256661100, "DUVUVA"], [89384897, "FOZIJA"], [26294306, "JEFOWA"], [264885135, "TEYABA"], [259371103, "NOREDA"], [246437428, "JEDUJE"], [21024561, "WABITO"], [215167635, "LOJORE"], [201236316, "SUMESE"], [178544572, "GEYOGE"], [15290498, "TAROBA"], [23330844, "TAFUBA"], [90943456, "HISABE"], [103080311, "GAVISA"], [31276046, "KIFAKA"], [18377430, "YIYAWU"], [48403129, "VUTIPE"], [18435047, "WIWUZO"], [89850690, "RIPIFO"]]How do I replace the first array's keys with the second set's values? And if it's not found, replace key with nil?


Awesome! Didn't realize it was that easy!

2019年04月20日25分39秒

Or, in point-free style: arr1.map(&h.method(:[])).

2019年04月19日25分39秒