Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Equivalent to java | operator in kotling

If i want to return two Gravity values at same time in java, I do this:

private int rightCenterVertical() {
   return Gravity.RIGHT | Gravity.CENTER_VERTICAL;
}

How can that be transformed to kotlin code?

To be honest, I don’t know how it’s called the "|" operator from java that is used to mix two values and return both of them.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

In kotlin it is just called or so your code would look like this:

fun rightCenterVertical(): Int {
   return Gravity.RIGHT or Gravity.CENTER_VERTICAL
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading