The all()
method in D evaluates if all the elements of an array are true. It returns true
if all values are true. Otherwise, it returns false
.
all(array)
array
: This is the array we want to check.
This method returns a Boolean value. If all the elements are true, it returns a true
value. Otherwise, it returns a false
value.
// Import std.stdio import std.stdio; import std.algorithm; // The main method void main(string[] args) { // Create an array int[] array1 = [50, 20, 10, 45, 34]; int[] array2 = [0, 1, 2, 3]; string[] array3 = [""]; // Check if the elements are true writeln(all(array1)); // true writeln(all(array2)); // false writeln(all(array2)); // false }
RELATED TAGS
CONTRIBUTOR
View all Courses