I wrote the if condition only to show that you should guarantee that card is not empty. You should not use such declarations inside the if code block because in this case names value and suit will be local relative to it.