@@ -345,7 +345,9 @@ kw"function"
345345"""
346346 return
347347
348- `return` can be used in function bodies to exit early and return a given value, e.g.
348+ `return x` causes the enclosing function to exit early, passing the given value `x`
349+ back to its caller. `return` by itself with no value is equivalent to `return nothing`
350+ (see [`nothing`](@ref)).
349351
350352```julia
351353function compare(a, b)
@@ -371,12 +373,15 @@ function test2(xs)
371373 end
372374end
373375```
374- In the first example, the return breaks out of its enclosing function as soon as it hits
376+ In the first example, the return breaks out of `test1` as soon as it hits
375377an even number, so `test1([5,6,7])` returns `12`.
376378
377379You might expect the second example to behave the same way, but in fact the `return`
378380there only breaks out of the *inner* function (inside the `do` block) and gives a value
379381back to `map`. `test2([5,6,7])` then returns `[5,12,7]`.
382+
383+ When used in a top-level expression (i.e. outside any function), `return` causes
384+ the entire current top-level expression to terminate early.
380385"""
381386kw " return"
382387
@@ -407,7 +412,7 @@ kw"if", kw"elseif", kw"else"
407412"""
408413 for
409414
410- `for` loops repeatedly evaluate the body of the loop by
415+ `for` loops repeatedly evaluate a block of statements while
411416iterating over a sequence of values.
412417
413418# Examples
@@ -425,8 +430,8 @@ kw"for"
425430"""
426431 while
427432
428- `while` loops repeatedly evaluate a conditional expression, and continues evaluating the
429- body of the while loop so long as the expression remains ` true` . If the condition
433+ `while` loops repeatedly evaluate a conditional expression, and continue evaluating the
434+ body of the while loop as long as the expression remains true. If the condition
430435expression is false when the while loop is first reached, the body is never evaluated.
431436
432437# Examples
@@ -473,19 +478,23 @@ kw"end"
473478"""
474479 try/catch
475480
476- A `try`/`catch` statement allows for `Exception`s to be tested for. For example, a
477- customized square root function can be written to automatically call either the real or
478- complex square root method on demand using `Exception`s:
481+ A `try`/`catch` statement allows intercepting errors (exceptions) thrown
482+ by [`throw`](@ref) so that program execution can continue.
483+ For example, the following code attempts to write a file, but warns the user
484+ and proceeds instead of terminating execution if the file cannot be written:
479485
480486```julia
481- f(x) = try
482- sqrt(x)
487+ try
488+ open("/danger", "w") do f
489+ println(f, "Hello")
490+ end
483491catch
484- sqrt(complex(x, 0))
492+ @warn "Could not write file."
485493end
486494```
487495
488- `try`/`catch` statements also allow the `Exception` to be saved in a variable, e.g. `catch y`.
496+ The syntax `catch e` (where `e` is any variable) assigns the thrown
497+ exception object to the given variable within the `catch` block.
489498
490499The power of the `try`/`catch` construct lies in the ability to unwind a deeply
491500nested computation immediately to a much higher level in the stack of calling functions.
@@ -561,7 +570,9 @@ kw"continue"
561570"""
562571 do
563572
564- Create an anonymous function. For example:
573+ Create an anonymous function and pass it as the first argument to
574+ a function call.
575+ For example:
565576
566577```julia
567578map(1:10) do x
@@ -842,7 +853,7 @@ nothing
842853"""
843854 Core.TypeofBottom
844855
845- The singleton type containing only the value `Union{}`.
856+ The singleton type containing only the value `Union{}` (which represents the empty type) .
846857"""
847858Core. TypeofBottom
848859
@@ -1246,7 +1257,7 @@ Unsigned
12461257"""
12471258 Bool <: Integer
12481259
1249- Boolean type.
1260+ Boolean type, containing the values `true` and `false` .
12501261"""
12511262Bool
12521263
0 commit comments