GLib.Variant.new_maybe

function new_maybe(child_type: GLib.VariantType, child: GLib.Variant): GLib.Variant {
    // Gjs wrapper for g_variant_new_maybe()
}
  

Depending on if child is null, either wraps child inside of a maybe container or creates a Nothing instance for the given @type.

At least one of child_type and child must be non-null. If child_type is non-null then it must be a definite type. If they are both non-null then child_type must be the type of child.

If child is a floating reference (see GLib.Variant.prototype.ref_sink), the new instance takes ownership of child.

Since 2.24

child_type

the GLib.VariantType of the child, or null

child

the child value, or null

Returns

a floating reference to a new GLib.Variant maybe instance