Skip to content

Instantly share code, notes, and snippets.

@giruzou
Last active November 5, 2018 07:13
Show Gist options
  • Save giruzou/5d8e8e868d57b62cb11273d698146161 to your computer and use it in GitHub Desktop.
Save giruzou/5d8e8e868d57b62cb11273d698146161 to your computer and use it in GitHub Desktop.
Ruby最大値(max)と最小値(min)の位置インデックス(index)を得る方法 ref: https://qiita.com/DrqYuto/items/4d4f0147659803e38d55
a=[1,2].each_with_index.max[1]+1
#=>2
a=[1,2].each_with_index.min[1]+1
=>1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment