return' is not allowed here
时间: 2023-12-26 21:06:29 浏览: 26
I apologize for the confusion. The `return` statement can only be used inside a function or method, and it cannot be used directly in the main body of the code.
If you want to return a value from a function or method, you need to define a function or method and use the `return` statement inside it. Here's an example:
```kotlin
fun initConfig(): PpOCRActivity {
val ppOcr = PpOCRActivity(applicationContext)
ppOcr.initConfig()
return ppOcr
}
// Calling the function and using the returned value
val ppOcr = initConfig()
```
In this example, the `initConfig()` function is defined to instantiate `PpOCRActivity` and initialize its configuration. Then, the created `ppOcr` object is returned from the function.
Please note that this example assumes that `PpOCRActivity` is a valid class in your codebase. If it's not, please replace it with the appropriate class or modify the code accordingly.