Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does object._("a string here") mean?

Tags:

java

I'm examining a source code written by someone else. I've encountered something like this:

x = new MyObject();
x._("somestring")  

What does this expression object._("a string here") mean?

like image 776
user2583844 Avatar asked Jul 15 '13 14:07

user2583844


2 Answers

It simply means you have a method whose name is _ in the class MyObject (or a superclass). There's nothing special, the _ character just happens to be valid in Java names.

You might be surprised because you don't see that often. And you don't see that often because "this practice is discouraged". It makes the code harder to read.

See here :

A variable's name can be any legal identifier — an unlimited-length sequence of Unicode letters and digits, beginning with a letter, the dollar sign "$", or the underscore character "_". The convention, however, is to always begin your variable names with a letter, not "$" or "_". Additionally, the dollar sign character, by convention, is never used at all. You may find some situations where auto-generated names will contain the dollar sign, but your variable names should always avoid using it. A similar convention exists for the underscore character; while it's technically legal to begin your variable's name with "_", this practice is discouraged. White space is not permitted

like image 113
Denys Séguret Avatar answered Oct 13 '22 16:10

Denys Séguret


Class MyObject has a method _() which accept String as input argument.

like image 38
Ruchira Gayan Ranaweera Avatar answered Oct 13 '22 16:10

Ruchira Gayan Ranaweera