0

Can I write "return(a*b)" istead of just "return a*b". It's so confusing now not to have parentheses.. Will it make difference?

13th Sep 2019, 10:25 PM
Mikael Ovakimyan
2 odpowiedzi
+ 3
Theres no difference between them in your example, parenthesis are used to order the way you want your code to operate. here we have 2 sums which are the same they both follow precedence but in last one I control the order using parenthesis which has a higher precedence over multiplication operator. (2*2+4*2) //output 12 2*2 = 4; 4*2 = 8; 4+8 = 12; (2*(2+4)*2) //output 24 2+4 = 6: 2*6 = 12; 12*2 = 24;
14th Sep 2019, 8:51 AM
D_Stark
D_Stark - avatar
0
Yes you can but make sure that there is a space after the return statement
13th Sep 2019, 10:27 PM
Qudusayo
Qudusayo - avatar