简体   繁体   中英

Scala idiom for comparing to java.lang.Long

What's the Scala idiom for comparing a long literal with a boxed java.lang.Long? I've come up with

myLong == new java.lang.Long(42L)

but it looks dreadful, and I'm hoping there's some cute syntax I'm not aware of.

Scala == uses .equals method internally. So it does boxing-unboxing automatically. As @Frank S. Thomas said the working way is

myLong == 42L

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM