例如,如果我跑
pry(main)> .ls
我想将文件列表放入一个可以在Ruby中使用的数组中.
我怎样才能做到这一点?
fizz = [] .ls | {|listing| fizz = listing.split("\n")} # can also be written as .ls do |listing| fizz = listing.split("\n") end