@@ -128,7 +128,7 @@ So, we could have defined the ``test`` function above as
128128
129129.. doctest ::
130130
131- julia> function test (x,y)
131+ julia> function test1 (x,y)
132132 if x < y
133133 relation = "less than"
134134 elseif x == y
@@ -138,7 +138,7 @@ So, we could have defined the ``test`` function above as
138138 end
139139 println("x is ", relation, " y.")
140140 end
141- test (generic function with 1 method)
141+ test1 (generic function with 1 method)
142142
143143The variable ``relation `` is declared inside the ``if `` block, but used
144144outside. However, when depending on this behavior, make sure all possible
@@ -147,22 +147,22 @@ the above function results in a runtime error
147147
148148.. doctest ::
149149
150- julia> function test (x,y)
150+ julia> function test2 (x,y)
151151 if x < y
152152 relation = "less than"
153153 elseif x == y
154154 relation = "equal to"
155155 end
156156 println("x is ", relation, " y.")
157157 end
158- test (generic function with 1 method)
158+ test2 (generic function with 1 method)
159159
160- julia> test (1,2)
160+ julia> test2 (1,2)
161161 x is less than y.
162162
163- julia> test (2,1)
163+ julia> test2 (2,1)
164164 ERROR: UndefVarError: relation not defined
165- in test (::Int64, ::Int64) at ./none:7
165+ in test2 (::Int64, ::Int64) at ./none:7
166166 in eval(::Module, ::Any) at ./boot.jl:237
167167
168168``if `` blocks also return a value, which may seem unintuitive to users
@@ -238,17 +238,17 @@ together:
238238
239239.. doctest ::
240240
241- julia> test (x, y) = println(x < y ? "x is less than y" :
241+ julia> test4 (x, y) = println(x < y ? "x is less than y" :
242242 x > y ? "x is greater than y" : "x is equal to y")
243- test (generic function with 1 method)
243+ test4 (generic function with 1 method)
244244
245- julia> test (1, 2)
245+ julia> test4 (1, 2)
246246 x is less than y
247247
248- julia> test (2, 1)
248+ julia> test4 (2, 1)
249249 x is greater than y
250250
251- julia> test (1, 1)
251+ julia> test4 (1, 1)
252252 x is equal to y
253253
254254To facilitate chaining, the operator associates from right to left.
@@ -684,15 +684,15 @@ if the argument is negative:
684684
685685.. doctest ::
686686
687- julia> f (x) = x>=0 ? exp(-x) : throw(DomainError())
688- f (generic function with 1 method)
687+ julia> g (x) = x>=0 ? exp(-x) : throw(DomainError())
688+ g (generic function with 1 method)
689689
690- julia> f (1)
690+ julia> g (1)
691691 0.36787944117144233
692692
693- julia> f (-1)
693+ julia> g (-1)
694694 ERROR: DomainError:
695- in f (::Int64) at ./none:1
695+ in g (::Int64) at ./none:1
696696 in eval(::Module, ::Any) at ./boot.jl:237
697697
698698Note that :exc: `DomainError ` without parentheses is not an exception, but a type of
@@ -808,17 +808,17 @@ call either the real or complex square root method on demand using
808808
809809.. doctest ::
810810
811- julia> f (x) = try
811+ julia> h (x) = try
812812 sqrt(x)
813813 catch
814814 sqrt(complex(x, 0))
815815 end
816- f (generic function with 1 method)
816+ h (generic function with 1 method)
817817
818- julia> f (1)
818+ julia> h (1)
819819 1.0
820820
821- julia> f (-1)
821+ julia> h (-1)
822822 0.0 + 1.0im
823823
824824It is important to note that in real code computing this function, one would
0 commit comments