Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有以下 Groovy 地图,
def mymap=["TXT_TXT":1,"IMG_TXT":2,"TXT_IMG":3,"IMG_IMG":4]
如何在此地图中找到元素的索引?
使用 findIndexOf 方法如下:
def mymap=["TXT_TXT":1,"IMG_TXT":2,"TXT_IMG":3,"IMG_IMG":4] assert 3 == mymap.findIndexOf{it.key=="IMG_IMG"} assert 0 == mymap.findIndexOf{it.value==1}