Mango:...:Number(3pm)
β¨ Mango:...:Number β¨
okay bestie, so this is Mango::BSON::Number from the User Contributed Perl Documentation β it's a little container that holds a number and a strict type, no vibes-based guessing allowed π
πΈ NAME πΈ
Mango::BSON::Number β numerical types, but make it typed π¦
β¨ SYNOPSIS β¨
use Mango::BSON;
use Mango::BSON::Number;
my $number = Mango::BSON::Number->new(666, Mango::BSON::INT64);
say $number;
like. that's it. that's the whole vibe. π
π DESCRIPTION π
Mango::BSON::Number is literally just a container for numerical values, except it comes with a strict type attached. no chaos, no "is this an int or a float" existential crisis at 3am. it knows. β¨
π METHODS π
Mango::BSON::Number inherits all methods from Mojo::Base and implements the following new ones, bestie π«Ά
π¦ new
my $number = Mango::BSON::Number->new(3.14, Mango::BSON::DOUBLE);
constructs a brand new Mango::BSON::Number object for you, iconique π
β οΈ it will croak if the value you give it is incompatible with the type you asked for. so don't try it. it's giving consequences.
the 3 supported types are DOUBLE, INT32 and INT64. only those three. periodt. β
π TO_JSON
my $num = $obj->TO_JSON;
returns the numerical value. that's the whole job, and it ate. π₯
πΈ to_string
my $str = $num->to_string;
returns the value as a string. string-ified. slayed. β¨
π isa_number
my $flags = Mango::BSON::Number::isa_number(25);
determines whether the variable you handed over is a number by peeking at the internal flags of the perl scalar object π (yes, we're looking at its insides, no cap).
returns undef if the value is not a number, or a non-null value otherwise. and that returned value contains flags you can use for a finer analysis of the scalar β iykyk π§
β guess_type
my $mongo_type = Mango::BSON::Number::guess_type(25);
picks which BSON type to use when encoding the numeric value you gave it. the possible types are Mango::BSON::DOUBLE, Mango::BSON::INT32 or Mango::BSON::INT64 π«
returns undef if the value you passed isn't a number. no number, no type, no drama. π
π OPERATORS π
Mango::BSON::Time overloads the following operators (yes it says Time, that's what the original says, we don't ask questions, we just report the facts π«‘).
π bool
my $bool = !!$num;
πΈ stringify
my $str = "$num";
alias for to_string β same energy, different outfit π
π SEE ALSO π
- Mango
- Mojolicious::Guides
- <http://mojolicio.us>
and that's the whole page, bestie π«Ά this iconic little number was brought to you by perl v5.30.3, dated 2020-06-05 β Mango:...:Number(3pm), no cap, fr fr πβ¨ππ¦πΈπ
π¦ where this page comes from
- debian bookworm: libmango-perl 1.30-2 Β· Artistic-2.0
- debian trixie: libmango-perl 1.30-2 Β· Artistic-2.0
- ubuntu jammy: libmango-perl 1.30-2 Β· Artistic-2.0
- ubuntu noble: libmango-perl 1.30-2 Β· Artistic-2.0
- ubuntu resolute: libmango-perl 1.30-2 Β· Artistic-2.0
- ubuntu stonking: libmango-perl 1.30-2 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms