Bash Question

How to pass an integer as an argument in Shell function and retrieve it

I have a small function like this -

#! /bin/sh
function hey() {
a=$1
echo $a
}

x=2
hey x


As per my understanding it should print
2
but it is printing
x
. How to resolve it?

Answer

Running you code in my bash (not sh) , it also prints x. But if i change the last line to

hey $x 

then it prints 2.