A usage pattern with !$ is:
% mkdir foo
% chmod g+s !$
% ls -ld !$ # (make sure it's correct)
% cd !$ % mkdir foo
% chmod g+s !$
% ls -ld !$ # (make sure it's correct)
% cd !$ $ chmod 755 foo
$ cd !$:p
cd foo
$ cd foo
There are some similar "tricks" here:So, when you press ! $ <space>, it expands out to "foo" in place, so you can be sure that's what you wanted, and edit it in place.
I think :p predates magic-space. They're both decades old at this point though.