I remember seeing a method somewhere that actually allowed only letters 'Uppercase', 'lowercase', numbers and the underscore in the name, but I can't find it again for the life of me.
Are any other characters allowed?
If you want to check which Characters are allowed in selector names you could use the RefactoringBrowser scanner and evaluate:
RBScanner isSelector: 'invalid@Selector'.
RBScanner isSelector: 'ValidSelector123_test'.
RBScanner isSelector: '111selector123_test'.
the same applies to instance variable names
RBCondition checkInstanceVariableName: 'validInstVar' in: UndefinedObject.
" true, valid instance variable name "
RBCondition checkInstanceVariableName: 'super' in: UndefinedObject.
" false, super is a reserved word in Smalltalk "
RBCondition checkInstanceVariableName: '' in: UndefinedObject.
" false, empty instance variables are not allowed "
RBCondition checkInstanceVariableName: 'Invalid' in: UndefinedObject.
" false, instance variable must start with lowercase character "
or class variables
RBCondition checkClassVarName: 'invalidClassVar' in: UndefinedObject.
" false, because class variables must start with uppercase "
RBCondition checkClassVarName: 'super' in: UndefinedObject.
" false, the same "
RBCondition checkClassVarName: '' in: UndefinedObject.
" false, empty Class variables are not allowed "
RBCondition checkClassVarName: 'Valid' in: UndefinedObject.
" true, a valid class variable "
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With