lambda

A collection of 1 post

Aug 12, 2016

Python 的世界里没有代码块

以前经常写 ruby 和 js, 对于以下的代码非常习惯: item = {id: 1, name: 'Donald Clinton'} attrs = [:id, :name] attr_getters = attrs.map do |attr| lambda do "The #{attr} is #{item[attr]}" end end > attr_