This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| snippets:iife [2018/03/20 11:23] – [c++] allspark | snippets:iife [2018/03/20 11:24] (current) – [go] allspark | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | # Immediately-invoked Function Expression | ||
| + | ## c++ | ||
| + | |||
| + | ```cpp | ||
| + | #include < | ||
| + | |||
| + | int main() { | ||
| + | [](int v) { | ||
| + | std::cout << v << std::endl; | ||
| + | }(42); | ||
| + | | ||
| + | return 0; | ||
| + | } | ||
| + | ``` | ||
| + | |||
| + | ## go | ||
| + | |||
| + | ```go | ||
| + | package main | ||
| + | |||
| + | import " | ||
| + | |||
| + | func main() { | ||
| + | func (v int) { | ||
| + | fmt.Println(v) | ||
| + | }(42); | ||
| + | } | ||
| + | ``` | ||
| + | |||
| + | ## javascript | ||
| + | |||
| + | ```javascript | ||
| + | (function (v) { | ||
| + | console.log(v); | ||
| + | })(42); | ||
| + | ``` | ||