Skip to content

Instantly share code, notes, and snippets.

@dteoh
Last active June 2, 2020 22:58
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save dteoh/fb90d5730ccb6df079140b6d249d8330 to your computer and use it in GitHub Desktop.
Solving "unused variable this." warnings when using ReasonML objects

unused variable this

You can create objects in ReasonML. For example:

let document = {
  pub title = "My Treatise";
  pub contents = "<a lot of words>"
};

If you compile this, you will most likely get warning number 27 with message unused variable this..

You can solve this by adding as _; as follows:

let document = {
  as _;
  pub title = "My Treatise";
  pub contents = "<a lot of words>"
};
@ValeTheVioletMote
Copy link

Why is this the case?

@dteoh
Copy link
Author

dteoh commented Jun 2, 2020

Why is this the case?

As in why is there a variable this? It is an object, and you can write functions in the object like:

pub someFunction = () => 42;
pub getAnswer = () => this#someFunction()

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