cbmanica
cbmanica

Reputation: 3879

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.

Upvotes: 0

Views: 428

Answers (1)

Arseniy Zhizhelev
Arseniy Zhizhelev

Reputation: 2401

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

myLong == 42L

Upvotes: 6

Related Questions