string: fix capitalize
							parent
							
								
									d51019dd77
								
							
						
					
					
						commit
						8be07194c7
					
				| 
						 | 
				
			
			@ -752,6 +752,9 @@ pub fn (s string) to_upper() string {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
pub fn (s string) capitalize() string {
 | 
			
		||||
	if s.len == 0 {
 | 
			
		||||
		return ''
 | 
			
		||||
	}
 | 
			
		||||
	sl := s.to_lower()
 | 
			
		||||
	cap := sl[0].str().to_upper() + sl.right(1)
 | 
			
		||||
	return cap
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -503,6 +503,8 @@ fn test_capitalize() {
 | 
			
		|||
	assert s.capitalize() == 'Test'
 | 
			
		||||
    s = 'i am ray'
 | 
			
		||||
	assert s.capitalize() == 'I am ray'
 | 
			
		||||
	s = ''
 | 
			
		||||
	assert s.capitalize() == ''
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
fn test_title() {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue