0
我有一個不一定是字符串的對象列表,我想返回已被大寫的字符串列表。Groovy collect()關閉不起作用來大寫字符串
目前,我這樣做:
// Input : ["foo", "bar"] (not actually strings)
// Expected Output : ["Foo", "Bar"]
// Actual Output : ["foo", "bar"]
// Code:
list.collect { it.toString().capitalize() }
可能是什麼問題?如果我打印出每個元素,然後收集它打印出正確的值,但最終的列表是錯誤的。