I try to concatenate some barcode values:
barcodeScanner.process(image)
.addOnSuccessListener {
barcodes ->
if (barcodes.isNotEmpty()) {
val barcode = barcodes.reduce {acc, barcode -> acc + barcode.rawValue() }
debug ("analyze: barcodes: $barcode")
} else {
debug ("analyze: No barcode scanned")
}
}
The code produces the following errors:
Type mismatch: inferred type is Unit but Barcode! was expected
Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public operator fun Offset.plus(offset: IntOffset): Offset defined in androidx.compose.ui.unit
public operator fun IntOffset.plus(offset: Offset): Offset defined in androidx.compose.ui.unit
Expression 'rawValue' of type 'String?' cannot be invoked as a function. The function 'invoke()' is not found
I understand none of them. Can anybody explain?
In particular the last error message sounds strange to me. Why do I try to call rawValue
on a String
? The variable barcodes
should be of the type List<Barcode>
and not List<String>
.