Go Built-In Function new: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 9: | Line 9: | ||
=Overview= | =Overview= | ||
The <tt>new()</tt> built-in function takes a type as argument, allocates memory of the given type and returns a pointer to it. | |||
<pre> | |||
var ptr *some_type | |||
ptr = new(some_type) | |||
</pre> |
Revision as of 01:21, 30 March 2016
External
- Specification https://golang.org/ref/spec#Allocation
Internal
Overview
The new() built-in function takes a type as argument, allocates memory of the given type and returns a pointer to it.
var ptr *some_type ptr = new(some_type)