Skip to content

Add destructuring #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
rpip opened this issue Apr 18, 2016 · 0 comments
Open

Add destructuring #20

rpip opened this issue Apr 18, 2016 · 0 comments

Comments

@rpip
Copy link
Owner

rpip commented Apr 18, 2016

Some examples of destructuring

  1. let {x,y,_} = {1,4,5}
let guess_type =  fn x ->
  case x do
      1 ->
          :number;
      3..10 ->
          :range;
      x::xs ->
          :list;
      {name = _} ->
          :record
  end
;;

x::y = [1,2,3] results in x = 1, y = [2,3]

x,y::xs = [1,2,3] results in x = 1, y = 2, xs = [3]

x,y::_ = [1,2,3] results in x = 1, y = 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant