• Post Reply Bookmark Topic Watch Topic
  • New Topic

Set a char to empty

 
Anthony Smith
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
char t;
How come I cannot say t = '';
WHat are my alternatives?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65661
129
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
char is a primitive type that contains a character value. Asking why it cannot be set to "empty" is like asking why an int can't be set to "empty".
The closest approximation is to set it to the null character a la:

hth,
bear
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!