简体   繁体   中英

Get a different result when calling the same function

I am a scala newbie.

This is my code. The results of two types of same method use are different, can anyone explain to me why???

在此处输入图片说明

The thing is that in Scala, all functions ( or "operators") which have names ending with a colon ':' are deemed as right associative when used with infix notation.

So... for your function,

def ::(t: TG) = ???

When, you are writing

val lxx3 = lxx1 :: lxx2

The function :: associates to the right (ie. with lxx2 ). So it is actually equivalent to

val lxx3 = lxx2.::(lxx1)

instead of this,

val lxx3 = lxx1.::(lxx2)

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