0

I have a test in a function to make sure the form fields are there.

Which of these would you use? and why?

  1. instead of trim(form[arguments.fieldname]) eq ""
  2. len(trim(form[arguments.fieldname])) eq 0

Is there a true benefit to either one over the other?

user2752132
  • 11
  • 1
  • 4

1 Answers1

0

They are equivalent. The choice is one of style. Do note that those who prefer len tend to use the return value as an implicit boolean (so, <cfif len(trim(form[arguments.fieldname]))>, without the eq 0), and this does seem to be generally regarded as more expressive.

But both work, and the performance differences are negligible. It is a question of readability, which is somewhat subjective.

See also.

Community
  • 1
  • 1
Tim Jasko
  • 1,532
  • 1
  • 8
  • 12