Module:...Boolean(3)

πŸ“¦ version 1.1.3, in alpine 3.24

hiii bestie! welcome to the manual page for Module:...Boolean(3) from the User Contributed Perl Documentation. it’s giving Boolean Representation Class, and it’s lowkey iconic. πŸ’…βœ¨


✨ NAME ✨

Module::Generic::Boolean β€” the Boolean Representation Class, aka your little true/false bestie. πŸ’–


πŸ¦‹ SYNOPSIS πŸ¦‹

okay so here’s the whole vibe in code, no cap:

my $bool = Module::Generic::Boolean->true;
# or
my $bool = Module::Generic::Boolean::true;
# Now I have a Module::Generic::Boolean object

# Returns 1
if( $bool )
{
    # Do something
}

my $hash =
{
    name => 'John Doe',
    active => $bool,
};
# Converting to json
print( JSON->new->encode( $hash ), "\n" );
# Would result in
{
    name: "Jogn Doe",
    active: true
}

πŸ“ VERSION πŸ“

v1.2.2 β€” that’s the version, bestie. ✨


🌸 DESCRIPTION 🌸

okay so this class/package is here to represent boolean values and make sure they’re recognised interchangeably as Perl booleans, i.e. 1 or 0, or as JSON bools, i.e. "true" or "false". it’s giving bilingual but make it booleans. πŸ’…

The code is taken and adapted from part of the JSON module. periodt. πŸ”₯


πŸ’… METHODS πŸ’…

here’s the method menu, bestie β€” every single one, no skipping. 🫢

πŸ¦‹ as_array

Returns a Module::Generic::Array object with the current boolean value as its only entry. iconic little singleton behaviour. ✨

my $true = Module::Generic::Boolean->true;
my $a = $true->as_array;
say $a->[0]; # 1

πŸ”₯ as_number

Returns the current boolean value (1 or 0) as a Module::Generic::Number object. numbers found slaying. πŸ’…

🌈 as_scalar

Returns the current boolean value (1 or 0) as a Module::Generic::Scalar object. scalar era. πŸŽ€

⭐ defined

Returns true. that’s it. that’s the whole method. iconic. πŸ‘‘

πŸ’œ is_bool

Provided with a value, and this returns true if it is a Module::Generic::Boolean object. vibe check: passed. βœ…

🌸 is_true

Provided with a value, and this returns true if it is a Module::Generic::Boolean object and this is true. true bestie behaviour. πŸ’–

πŸ¦‹ is_false

Provided with a value, and this returns true if it is a Module::Generic::Boolean object and this is false. respectful false recognition. πŸ™ˆ

πŸŽ€ true

This returns a Perl true value, i.e. 1, or "true" when added into JSON. slay. ✨

πŸ“ false

This returns a Perl false value, i.e. 0, or "false" when added into JSON. also slay. ✨

πŸ’… TO_JSON

This is called by JSON to transform an object into JSON data format. 🫢

It returns "\1" if true, or "\0" otherwise. Those values are understood by JSON and transcoded accordingly. iykyk. πŸ’œ


πŸŽ€ SERIALISATION πŸŽ€

Serialisation by CBOR, Sereal and Storable::Improved (or the legacy Storable) is supported by this package. To that effect, the following subroutines are implemented: FREEZE, THAW, STORABLE_freeze and STORABLE_thaw. literally serialisation main character energy. 🌈


🧡 THREAD SAFETY NOTE 🧡

Module::Generic::Boolean is thread-safe. ngl that’s a flex. πŸ’ͺ

Conversion methods like as_array, as_scalar, and as_number dynamically load external modules at runtime. To ensure maximum safety in multi-threaded environments, consider preloading those classes in the main thread:

use Module::Generic::Array;
use Module::Generic::Number;
use Module::Generic::Scalar;

These methods do not share state and are otherwise safe. no cap. ✨


πŸ’Œ AUTHOR πŸ’Œ

Jacques Deguest <jack@deguest.jp> β€” the author, bestie. 🫢


Copyright (c) 2000-2024 DEGUEST Pte. Ltd.

You can use, copy, modify and redistribute this package and associated files under the same terms as Perl itself.


πŸ’– cute sign-off: this page is from perl v5.42.2, dated 2026-02-15, and it’s all Module:...Boolean(3) β€” byeee, bestie! ✨🫢
πŸ“¦ where this page comes from