PHP 8.4.0 RC2 available for testing

Ds\Set::contains

(PECL ds >= 1.0.0)

Ds\Set::containsDetermines if the set contains all values

Açıklama

public Ds\Set::contains(mixed ...$values): bool

Determines if the set contains all values.

Bilginize:

Values of type object are supported. If an object implements Ds\Hashable, equality will be determined by the object's equals function. If an object does not implement Ds\Hashable, objects must be references to the same instance to be considered equal.

Dikkat

All comparisons are strict (type and value).

Bağımsız Değişkenler

values

Values to check.

Dönen Değerler

false if any of the provided values are not in the set, true otherwise.

Örnekler

Örnek 1 Ds\Set::contains() example

<?php
$set
= new \Ds\Set([1, 2, 3]);

var_dump($set->contains(1)); // true
var_dump($set->contains(1, 2)); // true
var_dump($set->contains(...[1, 2])); // true

var_dump($set->contains("1")); // false
var_dump($set->contains(...[1, 2, 3, 4])); // false

var_dump($set->contains(...[])); // true
?>

Yukarıdaki örnek şuna benzer bir çıktı üretir:

bool(true)
bool(true)
bool(true)
bool(false)
bool(false)
bool(true)
add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top