10.7: Have a custom Dock per Space: An awesome new feature in OSX Lion that is easily overlooked is the ability to customize the Dock in each Space.
By right clicking or Ctrl+clicking on a dock icon and then going to ‘Options’ you will notice the ability to assign that icon to ‘All Desktops’, ‘This Desktop’ or ‘None’. None is set by default.
A simple yet useful feature that was requested so many times in Snow Leopard.
[crarko adds: This is legitimately cool if you like to use custom Spaces, and a good follow-up to this hint.]
[Sweet.]
Source: Mac OS X Hints
This doesn’t appear to work as you thought it did. Doing that won’t prevent an icon from appearing in the dock if it’s assigned to another desktop. What it will do is that Mac OS will automatically switch to the desktop the app is assigned to when it’s clicked.