首页 > Linux操作系统 > Linux操作系统 > Ruby的下划线魔法
CODE:
people = {CODE:
people.map { |name, fields| [name, fields.last] }but it's not very clear what fields.last is. Ruby has some fairly powerful destructuring assignment, so we can reach inside the structure with parentheses to make things more explicit:CODE:
people.map { |name, (eye_color, email)| [name, email] }来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/301743/viewspace-745165/ ,如需转载,请注明出处,否则将追究法律责任。