Skip to content

Code snippet in chapter "Variables and Functions" exercises scoping and shadowing #51

Description

@reynir

Someone on IRC asked a question about the following snippet of code:

let concat ?sep x y =
let sep = match sep with None -> "" | Some x -> x in
x ^ sep ^ y
;;

I noticed the snippet exercises non-recursive let-bindings, scoping, and shadowing, and I think a newcomer would easily find it confusing to read. The user mentioned it might have been to reinforce earlier-learned concepts. If so, then maybe it would be a good idea to mention this :-)

Relevant logs from IRC: https://irclog.whitequark.org/ocaml/2018-05-23#1527056651-1527058456;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions