-6

Can someone tell me what this strange syntax is ? I tried to google it but could not get the correct hit.
Rating( movieName, rate: 5);

It looks like some kind of json syntax. what does "rate: 5" do ? Thanks

enter image description here

tadpole
  • 1,161
  • 7
  • 18
  • 27
  • 1
    Can you share a full snippet? This doesn't look like valid Java syntax. – Mureinik Jun 22 '19 at 14:38
  • It doesn't look like Java syntax to me. Where did you find it? – WJS Jun 22 '19 at 14:38
  • Where have you seen this code? Can you post the URL where you copied that line? – Progman Jun 22 '19 at 14:38
  • See: https://stackoverflow.com/questions/33652523/write-parameter-names-in-method-call – SDJ Jun 22 '19 at 14:44
  • 2
    This looks more like a feature of the IDE you are using to show the parameter names. Which IDE are you using? – Progman Jun 22 '19 at 14:45
  • 5
    The `rating:` that you see is not part of the code. It's a hint that is displayed by the IDE (IntelliJ in this case) to make the code easier to understand. – JB Nizet Jun 22 '19 at 14:45
  • This looks like the [parameter hints in IntelliJ](https://stackoverflow.com/questions/40627924/intellij-idea-how-to-always-show-method-parameter-names) – SDJ Jun 22 '19 at 14:49
  • Oh, I see. This was just a tutorial video that I saw. I have never seen that syntax. I thought it might be a new feature in java. I would assume the actual syntax would be Rating( "5678", 3). Thanks – tadpole Jun 22 '19 at 14:50

1 Answers1

3

The real syntax, eventually parsed by the compiler, is:

new Rating("1234", 4);

The string you see preceding the parameter are just type hint from your IDE.

Stefano Maglione
  • 3,695
  • 10
  • 43
  • 85