Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does this .get(x) behavior come from?

Some("abcdefg").get(3)  //res0: Char = d

The argument to get() is sent to the apply() method of the String, but the source code for Option (and Some) doesn't have a get() method that takes parameters, and String has no get method at all.

So what get() is being invoked? Is it a mole from Java land?

like image 305
jwvh Avatar asked Jul 02 '19 09:07

jwvh


People also ask

Why is human behavior so complex?

However, as you have seen in the previous sections, human behavior is quite complex as it is influenced, modulated and shaped by multiple factors which are often unrecognized by the individual: Overt or covert, logical or illogical, voluntary or involuntary.

Why do people behave the way they do?

Research on human behavior addresses how and why people behave the way they do. However, as you have seen in the previous sections, human behavior is quite complex as it is influenced, modulated and shaped by multiple factors which are often unrecognized by the individual: Overt or covert, logical or illogical, voluntary or involuntary.

What exactly is behavior?

So What Exactly is Behavior? In scientific research, human behavior is a complex interplay of three components: actions, cognition, and emotions. Sounds complicated? Let’s address them one by one.

How to fix “you have been kicked due to unexpected client behavior”?

How to fix “You have been kicked due to unexpected client behavior” in Roblox To fix “You have been kicked due to unexpected client behavior” in Roblox, you need to open the Roblox folder. Once you’re in the Roblox folder, you need to delete 3 files. The files are “AnalysticsSettings”, “frm.cfg”, and “GlobalBasicSettings_13”.


2 Answers

It is StringOps.apply from implicit conversion

augmentString(Some("abcdefg").get)(3)

where augmentString is

@inline implicit def augmentString(x: String): StringOps = new StringOps(x)
like image 148
Mario Galic Avatar answered Nov 04 '22 14:11

Mario Galic


Actually, in this case .get(x) is not a separate get() method but an abbreviation for .get.apply(x). So it's the standard get method on the Some type. No implicits required.

Some(Seq(99,32,12,7,101)).get(3)  //res0: Int = 7

Many thanks to @Mario Galic for pointing me in the right direction.

like image 32
jwvh Avatar answered Nov 04 '22 13:11

jwvh