您能为Ruby中的map(&:Method)语法提供参数吗?
a
a.map(&:method)
>> a=[:a, 'a', 1, 1.0]=> [:a, "a", 1, 1.0]>> a.map(&:class)=> [Symbol, String, Fixnum, Float]
a.map(&:class)a.map {|x| x.class}.
&:classclass
a = [1,3,5,7,9]a.map {|x| x + 2}&:
&:&:
+
>> a=1=> 1>> a+(1)=> 2>> a.send(:+, 1)=> 2
智慧大石
随时随地看视频慕课网APP
相关分类