Lets say, I have a variable:var myObject : MyObject? = nullit should be cleared in some place : and should be definitely non-nullable in a place of usage. In Java I can do something like this:
In Java sometimes i write the code as follows:In Kotlin compile-time error is shown:Assignments are not expressions, and only expressions are allowed in this context
For example when I type in *.kt file: Observable.unsafeCreate{} and then press Ctrl+Space between {} , then IntellijIdea suggest me to type symbol t ->, but when I do the same in .java file result is subscriber -> :
I need merge maps mapA andmapB with pairs of "name" - "phone number" into the final map, sticking together the values for duplicate keys, separated by commas. Duplicate values should be added only once. I need the most idiomatic and correct in terms of language approach.
My code is as belowThe compiler tell meRedundant 'if' statement less... (Ctrl+F1) This inspection reports if statements which can be simplified to single statements. For example: if (foo()) { return true } else { return false } can be simplified to return foo().
Any ideas why null-safe Kotlin function return null?It's a bug caused by introducing contracts for the standard functions let, run, apply, also in Kotlin 1.3.
I did notice some classes are highlighted in blue in my project structure. What is the reason?To expand on tyczj's answer, if version control is being used on the project then file names may be highlighted in different colours in the file explorer, editor tabs and active changes tab:
I'm trying to use WorkManager from architecture components. I've upgraded the compileSdkVersion and targetSdkVersion from 27 to 28. gradle sync is successfully done. But build-time error keeps popping up. android.support libraries are using version 28.0.0-rc02 because of the 'android.support:design'.