Saikumar
Saikumar

Reputation: 897

Convert Java assignment expression to Kotlin

enter image description here

Recently I converted the Java code into the Kotlin like pushnotification. After the conversion its shown some error and indicate to manually correct those issues.

In Java:

.addFlags(notifyDetails.flags |= Notification.FLAG_AUTO_CANCEL); 

After the conversion it's shown like

.addFlags(notifyDetails!!.flags notifyDetails!!.flags or Notification.FLAG_AUTO_CANCEL)

Also, it's indicating an error. How do I fix this?

Upvotes: 0

Views: 217

Answers (1)

yole
yole

Reputation: 97148

Kotlin doesn't allow you to use assignments such as |= as part of an expression. You need to split this into two expressions:

notifyDetailsFlags = notifyDetailsFlags or Notification.FLAG_AUTO_CANCEL

// the beginning of the call
.addFlags(notifyDetailsFlags)

Upvotes: 3

Related Questions