File tree Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Original file line number Diff line number Diff line change 9
9
class DetectCapital {
10
10
func detectCapitalUse( _ word: String ) -> Bool {
11
11
var capitalNum = 0 , isFirstUpperCased = false
12
-
13
- for char in word. characters {
12
+
13
+ for char in word {
14
14
if char. isUpperCased ( ) {
15
15
capitalNum += 1
16
16
}
17
17
}
18
-
19
- if let firstChar = word. characters . first {
18
+
19
+ if let firstChar = word. first {
20
20
isFirstUpperCased = firstChar. isUpperCased ( )
21
21
}
22
-
23
- return capitalNum == 0 || ( capitalNum == 1 && isFirstUpperCased) || capitalNum == word. characters . count
22
+
23
+ return capitalNum == 0 || ( capitalNum == 1 && isFirstUpperCased) || capitalNum == word. count
24
24
}
25
25
}
26
26
27
27
fileprivate extension Character {
28
- func isUpperCased( ) -> Bool {
29
- return String ( self ) . uppercased ( ) == String ( self )
30
- }
31
- }
28
+ func isUpperCased( ) -> Bool {
29
+ return String ( self ) . uppercased ( ) == String ( self )
30
+ }
31
+ }
You can’t perform that action at this time.
0 commit comments