Conversión a Boolean

toBoolean

public Boolean toBoolean()

Converts the given string into a Boolean object. If the trimmed string is "true", "y" or "1" (ignoring case) then the result is true othewrwise it is false.

Returns: The Boolean value

Since: 1.0

generaciondecodigos@nereida:~/src/groovy/strings$ cat -n ./StringToBoolean.groovy
     1  #!/usr/bin/env groovy
     2  assert "y".toBoolean()
     3  assert 'TRUE'.toBoolean()
     4  assert '  trUe  '.toBoolean()
     5  assert " y".toBoolean()
     6  assert "1".toBoolean()
     7
     8  assert ! 'other'.toBoolean()
     9  assert ! '0'.toBoolean()
    10  assert ! 'no'.toBoolean()
    11  assert ! '  FalSe'.toBoolean()



Casiano Rodríguez León
2010-04-30