Forums Register Login

How to test if a char equals something

+Pie Number of slices to send: Send
having trouble with this clip of code:


Can someone tell me the proper format to find the value of char? Thanks
+Pie Number of slices to send: Send
Assuming that word is a String (please be more complete), charAt() is the proper method to find the character at the specified position. Why do you feel that it may not be?

Also, wondering why you are comparing it against the value 1; that's not a printable character. If you are trying to compare it against the character '1', then the expression would be a == '1'.
+Pie Number of slices to send: Send
 

Bear Bibeault wrote:
If you are trying to compare it against the character '1', then the expression would be a == '1'.



This was the answer to my question. I had forgotten about the ' symbol used for chars.
It's exactly the same and completely different as this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 20803 times.
Similar Threads
not dereferenced error
Recursion
What does this mean?
Shuffle a string
char cannot be dereferenced
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 09:56:23.