---
layout: ../../../layouts/DocsLayout.astro
title: Anonymous classes
---
import Code from "../../../components/Code.astro"

# Anonymous classes


<Code thpcode={`
class Logger
{
    pub fun log(String msg)
    {
        print(msg)
    }
}

// Using a class instance
setLogger(Logger())

// Using an anonymous class
setLogger(class
{
    pub fun log(String msg)
    {
        print(msg)
    }
})
`} />

<Code thpcode={`
setLogger(class(Int param1) -> SomeClass(param1), SomeInterface
{
    pub fun method()
    {
        // code
    }
})
`} />
