juan_gandhi: (VP)
Juan-Carlos Gandhi ([personal profile] juan_gandhi) wrote2015-03-05 08:43 pm
Entry tags:

scala hacker writes javascript...

s0.toUpperCase().contains(s1.toUpperCase)


guess what will happen

[identity profile] sassa-nf.livejournal.com 2015-03-06 07:48 am (UTC)(link)
не компилируется

[identity profile] victorgr.livejournal.com 2015-03-06 07:53 am (UTC)(link)
А, ну наверняка потому что .contains ожидает тип string, а получает на вход тип function?

[identity profile] sassa-nf.livejournal.com 2015-03-06 08:01 am (UTC)(link)
угу

[identity profile] triampurum.livejournal.com 2015-03-09 06:50 pm (UTC)(link)
там второй .toUpperCase будет вызван как метод с нулем аргументов, в contains попадет строка, будет Boolean на выходе. Другими словами, в scala вызовы метод со скобочками и без скобочек в этом вот случае эквивалентны с т.з. компилятора.