isimmutable
.. isimmutable(v)
Return ``true`` iff value ``v`` is immutable. See :ref:`man-immutable-composite-types` for a discussion of immutability.
Note that this function works on values, so if you give it a type, it will tell you that a value of ``DataType`` is mutable.Examples
The isimmutable function in Julia is used to determine whether a given value is immutable or not. It returns true if the value is immutable, and false otherwise. Here are some examples of how to use the isimmutable function:
-
Check if an integer is immutable:
julia> isimmutable(5) trueThe
isimmutablefunction returnstruefor immutable values like integers. -
Check if a string is immutable:
julia> isimmutable("Julia") trueStrings are immutable in Julia, so the
isimmutablefunction returnstruefor them. -
Check if an array is immutable:
julia> isimmutable([1, 2, 3]) falseArrays are mutable in Julia, so the
isimmutablefunction returnsfalsefor them. -
Check if a custom composite type is immutable:
julia> struct Person name::String age::Int end julia> isimmutable(Person("Alice", 25)) falseCustom composite types are mutable by default unless explicitly defined as immutable. In this example, the
isimmutablefunction returnsfalsefor thePersonobject.
Please note that the isimmutable function works on values, not types. If you provide a type to the function, it will tell you that a value of that type is mutable.
See Also
BigFloat, BigInt, Dict, eltype, fieldtype, Float32, Float64, IntSet, isa, isalnum, isalpha, isascii, iseltype, isequal, isgraph, isimmutable, isinteractive, isleaftype, isnull, ispunct, isspace, issubtype, keytype, Nullable, NullException, promote_type, typeintersect, typejoin, typemax, typemin, typeof, Val, valtype,User Contributed Notes
Add a Note
The format of note supported is markdown, use triple backtick to start and end a code block.