Last active
          January 16, 2020 14:20 
        
      - 
      
 - 
        
Save youmee/bc23dd6088e59609609f to your computer and use it in GitHub Desktop.  
    Swift Russian Plural Form Function
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | /* | |
| pluralForm(28, forms: ["год", "года", "лет"]) | |
| output: "лет" | |
| */ | |
| func pluralForm(number: Int, forms: [String]) -> String { | |
| return number % 10 == 1 && number % 100 != 11 ? forms[0] : | |
| (number % 10 >= 2 && number % 10 <= 4 && (number % 100 < 10 || number % 100 >= 20) ? forms[1] : forms[2]) | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
Thanks dude!