• 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
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

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!
 
Sheriff
Posts: 28436
104
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!
 
The fastest and most reliable components of any system are those that are not there. Tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic