Packages

p

com.nthportal

convert

package convert

Ordering
  1. Alphabetic
Visibility
  1. Public
  2. All

Type Members

  1. sealed trait Convert extends AnyRef

    An object for handling a conversion between two types.

    An object for handling a conversion between two types.

    Convert.Valid returns the result of a conversion as is, and throws an exception if the conversion fails.

    Convert.Any returns the result of a conversion wrapped in an Option, and returns None if the conversion fails.

    Example:
    1. /* Convert a string to a boolean */
      def parseBoolean(s: String)(implicit c: Convert): c.Result[Boolean] = {
        c.conversion {
          s.toLowerCase match {
            case "true" => true
            case "false" => false
            case _ => c.fail(new IllegalArgumentException(s"'$s' is not 'true' or 'false'"))
          }
        }
      }
      
      val res1: Boolean = parseBoolean("true")(Convert.Valid)
      val res2: Option[Boolean] = parseBoolean("true")(Convert.Any)

Value Members

  1. object Convert

Ungrouped