• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Difference between return true; and return [true];

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Greetings! I have a simple question.
Reading some functions around the Internet, I found that there are some functions that have a return statement "return true;" (or "return false;") and there are others that have "return [true];" (or "return [false];"). Is there any difference between "return true;" and "return [true];"?

Thank you so much for making this clear! Thanks!
 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A simple question? Does that imply you're looking for a simple answer? The simple answer is "Yes".

However, since in real life the simplicity of a question is completely unrelated to the simplicity of its answer, I will give you the real answer.

The [] notation indicates that an array literal is being used. For example [true] represents an array with one element whose value is true. And since an array with one element whose value is true is different than the boolean value true, then the answer is "Yes, there is a difference".
 
Liwuen Chew
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your response. That resolves my concern.
Thank you so much!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic