@@ -735,6 +735,17 @@ defmodule Kernel do
735
735
Returns `true` if `term` is a floating-point number, otherwise returns `false`.
736
736
737
737
Allowed in guard tests. Inlined by the compiler.
738
+
739
+ ## Examples
740
+
741
+ iex> is_float(2.15)
742
+ true
743
+
744
+ iex> is_float(3.45e5)
745
+ true
746
+
747
+ iex> is_float(5)
748
+ false
738
749
"""
739
750
@ doc guard: true
740
751
@ spec is_float ( term ) :: boolean
@@ -786,6 +797,14 @@ defmodule Kernel do
786
797
Returns `true` if `term` is an integer, otherwise returns `false`.
787
798
788
799
Allowed in guard tests. Inlined by the compiler.
800
+
801
+ ## Examples
802
+
803
+ iex> is_integer(5)
804
+ true
805
+
806
+ iex> is_integer(5.0)
807
+ false
789
808
"""
790
809
@ doc guard: true
791
810
@ spec is_integer ( term ) :: boolean
@@ -797,6 +816,17 @@ defmodule Kernel do
797
816
Returns `true` if `term` is a list with zero or more elements, otherwise returns `false`.
798
817
799
818
Allowed in guard tests. Inlined by the compiler.
819
+
820
+ ## Examples
821
+
822
+ iex> is_list([1, 2, 3])
823
+ true
824
+
825
+ iex> is_list(key: :sum, value: 3)
826
+ true
827
+
828
+ iex> is_list({1, 2, 3})
829
+ false
800
830
"""
801
831
@ doc guard: true
802
832
@ spec is_list ( term ) :: boolean
@@ -809,6 +839,17 @@ defmodule Kernel do
809
839
otherwise returns `false`.
810
840
811
841
Allowed in guard tests. Inlined by the compiler.
842
+
843
+ ## Examples
844
+
845
+ iex> is_number(2.15)
846
+ true
847
+
848
+ iex> is_number(5)
849
+ true
850
+
851
+ iex> is_number(:one)
852
+ false
812
853
"""
813
854
@ doc guard: true
814
855
@ spec is_number ( term ) :: boolean
@@ -820,6 +861,18 @@ defmodule Kernel do
820
861
Returns `true` if `term` is a PID (process identifier), otherwise returns `false`.
821
862
822
863
Allowed in guard tests. Inlined by the compiler.
864
+
865
+ ## Examples
866
+
867
+ iex> {:ok, agent_pid} = Agent.start_link(fn -> 0 end)
868
+ iex> is_pid(agent_pid)
869
+ true
870
+
871
+ iex> is_pid(self())
872
+ true
873
+
874
+ iex> is_pid(:pid)
875
+ false
823
876
"""
824
877
@ doc guard: true
825
878
@ spec is_pid ( term ) :: boolean
@@ -831,6 +884,15 @@ defmodule Kernel do
831
884
Returns `true` if `term` is a port identifier, otherwise returns `false`.
832
885
833
886
Allowed in guard tests. Inlined by the compiler.
887
+
888
+ ## Examples
889
+
890
+ iex> [port | _] = Port.list()
891
+ iex> is_port(port)
892
+ true
893
+
894
+ iex> is_port(:port)
895
+ false
834
896
"""
835
897
@ doc guard: true
836
898
@ spec is_port ( term ) :: boolean
@@ -842,6 +904,15 @@ defmodule Kernel do
842
904
Returns `true` if `term` is a reference, otherwise returns `false`.
843
905
844
906
Allowed in guard tests. Inlined by the compiler.
907
+
908
+ ## Examples
909
+
910
+ iex> ref = make_ref()
911
+ iex> is_reference(ref)
912
+ true
913
+
914
+ iex> is_reference(:ref)
915
+ false
845
916
"""
846
917
@ doc guard: true
847
918
@ spec is_reference ( term ) :: boolean
@@ -853,6 +924,17 @@ defmodule Kernel do
853
924
Returns `true` if `term` is a tuple, otherwise returns `false`.
854
925
855
926
Allowed in guard tests. Inlined by the compiler.
927
+
928
+ ## Examples
929
+
930
+ iex> is_tuple({1, 2, 3})
931
+ true
932
+
933
+ iex> is_tuple({})
934
+ true
935
+
936
+ iex> is_tuple(true)
937
+ false
856
938
"""
857
939
@ doc guard: true
858
940
@ spec is_tuple ( term ) :: boolean
0 commit comments