trues

trues(dims)

Create a BitArray with all values set to true

Examples

  1. Create a 1-dimensional BitArray with all true values:

    julia> trues(5)
    5-element BitArray{1}:
    true
    true
    true
    true
    true

    This example creates a 1-dimensional BitArray of length 5 with all elements set to true.

  2. Create a 2-dimensional BitArray with all true values:

    julia> trues((2, 3))
    2×3 BitArray{2}:
    true  true  true
    true  true  true

    It creates a 2-dimensional BitArray with 2 rows and 3 columns, where all elements are set to true.

  3. Create a 3-dimensional BitArray with all true values:

    julia> trues((2, 2, 2))
    2×2×2 BitArray{3}:
    [:, :, 1] =
    true  true
    true  true
    
    [:, :, 2] =
    true  true
    true  true

    This example creates a 3-dimensional BitArray with size 2x2x2, where all elements are set to true.

Common mistake example:

julia> trues(-2)
ERROR: ArgumentError: dimensions must be non-negative

In this example, a negative dimension is provided, which is not allowed. The dims argument must be a non-negative integer or a tuple of non-negative integers.

See Also

all, all!, angle, any, any!, falses, ifelse, is, isinf, isinteger, isnan, isperm, ispow2, isreal, trues,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: