大概有两个片段:
// Verbose version val typedArray = context.obtainStyledAttributes(attrs, styleable) block(typedArray) typedArray.recycle()
// One-line version context.obtainStyledAttributes(attrs, styleable).also(block).recycle()
我想知道为什么冗长的代码块在Android Studio中看起来不错,而单行版本突出显示了getStyleStyledAttributes并给出以下警告:
与#recycle()一起使用后,应回收此TypedArray。
有谁知道这仅仅是一个Android Studio的绒毛检查缺陷,还是单行版本实际上有问题?