# 'return new'

**URL:** <https://discourse.julialang.org/t/return-new/110387>\
**Category:** General Usage\
**Tags:** question\
**Created:** [February 19, 2024, 2:39am UTC](https://discourse.julialang.org/t/return-new/110387 "2024-02-19T02:39:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jiang\_ming\_zhang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jiang_ming_zhang/32/204063_2.png) [@jiang\_ming\_zhang](https://discourse.julialang.org/u/jiang_ming_zhang)\
**Post date:** [February 19, 2024, 2:39am UTC](https://discourse.julialang.org/t/return-new/110387/1 "2024-02-19T02:39:49Z")

</div>

I saw code like

```julia
return new{T}(a, b)

```

as the last the line of some constructor function of a struct.

I am wondering what is the purpose of ‘new’ here? Typically, we see

```julia
return (a,b)

```

---

<div class="post-metadata">

**Author:** ![screw\_dog](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/screw_dog/32/48119_2.png) [@screw\_dog](https://discourse.julialang.org/u/screw_dog)\
**Post date:** [February 19, 2024, 2:51am UTC](https://discourse.julialang.org/t/return-new/110387/2 "2024-02-19T02:51:40Z")

</div>

In [inner constructors](https://docs.julialang.org/en/v1/manual/constructors/#man-inner-constructor-methods) (ie constructors _within_ the `struct` block) you can’t call a constructor by name since it hasn’t been defined yet, so we use the `new` keyword.

That is, `new{T}(a, b)` should be in a context like:

```julia
struct Foo{T} where T
    a::T
    b::T
    function Foo(a, b)
        # do some checks on a, b
        return new{T}(a, b)
    end
end

```

Here we use `new` to do the actual allocation/construction of the type.
