Skip to content

Latest commit

 

History

History
35 lines (25 loc) · 1016 Bytes

language_open.mdx

File metadata and controls

35 lines (25 loc) · 1016 Bytes
idkeywordsnamesummarycategory
open
open
module
open
This is the `open` keyword.
languageconstructs

open is used to expose all values, types, modules, etc of a module in the current scope. This is useful whenever you want to use a module's functionality without typing out the module name over and over again.

In some cases, open will cause a "shadow warning" due to existing identifiers and types being redefined by an opened module. You can explicitly ignore that warning by using an open! statement instead.

Example

<CodeTab labels={["ReScript", "JS Output"]}>

openMath// Use _PI and pow_float from the Math moduleletarea=radius=>Constants.pi*.pow(radius, ~exp=2.0)
functionarea(radius){returnMath.PI*Math.pow(radius,2.0);}

References

close