randompascalparentheses

Pascal : What's the difference between random(); and random;


Whether I use random or random(), I 'seem' to get the same results. Now, coming from a Python background, using random() seems more natural and convenient to me, but I've seen random being used plenty a times.

Neither statements produce a hint or a warning using FPC's appropriate flags.

So, is there a difference, and if yes, what is it?


Solution

  • There's no difference. Pascal doesn't require the parentheses when calling functions without parameters. You can use them to make your code more clear when reading it, but they're entirely optional.