gpt4 book ai didi

ruby - 有没有更简洁的方法在 Ruby 中调用 map 上的外部方法?

转载 作者:数据小太阳 更新时间:2023-10-29 07:56:20 26 4
gpt4 key购买 nike

<分区>

有没有更简洁的方法?

# Given a directory containing subdirectories: foo, bar
targets = ['./foo', './bar', './free']
targets.map{ |d| Dir.exists? d }
# => [ true, true, false ]

我希望能够做一些类似于 proc 调用的事情......感觉更干净:

# targets.map( Dir.exists? )

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com