The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Sidef::Convert::Convert

DESCRIPTION

This module helps with the conversion between object types.

SYNOPSIS

This module can only be used as a parent:

        our @ISA = qw(Sidef::Convert::Convert);

or

        use parent qw(Sidef::Convert::Convert);

INHERITS

Inherits methods from:

    * Sidef

METHODS

toArray

Obj.toArray() -> Array

Convert the self object into an array.

    "str".toArray  =>  ["str"]

Aliases: to_array().

Returns an object of type: Sidef::Types::Array::Array

toBool

Obj.toBool() -> Bool

Convert the self object into a boolean value.

      1.toBool   =>   true
    "0".toBool   =>   false

Aliases: to_bool().

Returns an object of type: Sidef::Types::Bool::Bool

toByte

Obj.toByte() -> Byte

Convert the self object into a numeric byte value.

    "a".toByte   =>   97

Aliases: to_byte().

Returns an object of type: Sidef::Types::Byte::Byte

toBytes

Obj.toBytes() -> Bytes

Convert the self object into an array of bytes,

    "abc".toBytes  =>  [97, 98, 99]

Aliases: to_bytes().

Returns an object of type: Sidef::Types::Byte::Bytes

to_c

Convert.to_c() -> Obj

Return the

Aliases: to_complex, toComplex

to_caller

Convert.to_caller() -> Obj

Return the

Aliases: toCaller

toChar

Obj.toChar() -> Char

Convert the self object into a character object.

        4.toChar   =>   "4"
    "xyz".toChar   =>   "x"

Aliases: to_char().

Returns an object of type: Sidef::Types::Char::Char

toChars

Obj.toChars() -> Chars

Convert the self object into an array of characters.

    "abc".toChars   => ['a', 'b', 'c']

Aliases: to_chars().

Returns an object of type: Sidef::Types::Char::Chars

toDir

Obj.toDir() -> Dir

Convert the self object into a directory type-object.

    '/my/dir'.toDir  =>  qd(/my/dir)

Aliases: to_dir().

Returns an object of type: Sidef::Types::Glob::Dir

to_f

Convert.to_f() -> Obj

Return the

Aliases: to_float, toFloat

to_fcaller

Convert.to_fcaller() -> Obj

Return the

Aliases: toFcaller

toFile

Obj.toFile() -> File

Convert the self object into a file type-object.

    '/my/file'.toFile  =>  qf(/my/file)

Aliases: to_file().

Returns an object of type: Sidef::Types::Glob::File

to_i

Obj.to_i() -> Num

Convert the self object into an integer.

    "12.34".to_i  =>  12
    332.999.to_i  =>  332

Aliases: toInt(), to_int(), toInteger(), to_integer().

Returns an object of type: Sidef::Types::Number::Number

toNum

Obj.toNum() -> Num

Convert the self object into a number type-object.

    "12.34".toNum  =>  12.34
      12.34.toNum  =>  12.34

Aliases: to_num().

Returns an object of type: Sidef::Types::Number::Number

to_obj

Convert.to_obj() -> Obj

Return the

Aliases: to_object

to_r

Convert.to_r() -> Obj

Return the

Aliases: to_rat, toRat, to_rational, toRational

toRegex

Obj.toRegex() -> Regex

Convert the self object into a regular expression.

    '([a-z])'.toRegex   =>  qr/([a-z])/

Aliases: to_re(), to_regex(), toRe().

Returns an object of type: Sidef::Types::Regex::Regex

toString

Obj.toString() -> String

Convert the self object into a string type-object.

When the self object is an array-like object, its elements will be joined one-level deep with a space character.

         42.toString  => '42'
    [1,2,3].toString  => '1 2 3'

Aliases: to_s(), to_str(), to_string(), toStr().

Returns an object of type: Sidef::Types::String::String