What is the difference between boolean value true() and true.

What exactly difference between true() and true.

true() is a function.

true is boolean value.


But we can use both anywhere and it works.

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer
    I think basic difference is Time and Space complexity
    both are different types and used accordingly,

    consider a scenario- create an array of {true,true,.......true} of length 50
    common approach is repeat(true,50) which takes 5 to 10 Ms to execute the code but use less memory resource.

    instead if you use apply(fn!true,enumerate(50)) it takes <1 Ms to execute
    so this improves the performance, but use more memory resource because we are calling 3 functions

    but apply function need function as 1st parameter but not the value.
    so both true() and true looks same but used according to requirements.
Reply
  • 0
    Certified Senior Developer
    I think basic difference is Time and Space complexity
    both are different types and used accordingly,

    consider a scenario- create an array of {true,true,.......true} of length 50
    common approach is repeat(true,50) which takes 5 to 10 Ms to execute the code but use less memory resource.

    instead if you use apply(fn!true,enumerate(50)) it takes <1 Ms to execute
    so this improves the performance, but use more memory resource because we are calling 3 functions

    but apply function need function as 1st parameter but not the value.
    so both true() and true looks same but used according to requirements.
Children
No Data