ruby
a=[1,2].each_with_index.max[1]
# =>1
a=[1,2].each_with_index.min[1]
# =>0
1番から始めたい場合
ruby
a=[1,2].each_with_index.max[1]+1
# =>2
a=[1,2].each_with_index.min[1]+1
=>1
Go to list of users who liked
More than 5 years have passed since last update.
a=[1,2].each_with_index.max[1]
# =>1
a=[1,2].each_with_index.min[1]
# =>0
1番から始めたい場合
a=[1,2].each_with_index.max[1]+1
# =>2
a=[1,2].each_with_index.min[1]+1
=>1
Register as a new user and use Qiita more conveniently
Go to list of users who liked