Access custom variable in blocks

how can we access custom variables inside define block?

{{ $bam := "ham" }}
{{ define "main" }}
  {{ $bam }}
{{ end }}

$ hugo version
Hugo Static Site Generator v0.54.0 darwin/amd64 BuildDate: unknown

Thanks.

You can try using .Scratch: https://gohugo.io/functions/scratch