Skip to content

Commit

Permalink
use index from end expressions (#1431)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp authored Feb 22, 2024
1 parent 6ff7d81 commit 9ebca0d
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ string Convert(int number, bool isOrdinal)
}
else if (isOrdinal)
{
parts[parts.Count - 1] += "ste";
parts[^1] += "ste";
}

var toWords = string.Join(" ", parts);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ string ConvertImpl(long number, bool isOrdinal)
}
else if (isOrdinal)
{
parts[parts.Count - 1] += "երորդ";
parts[^1] += "երորդ";
}

var toWords = string.Join(" ", parts);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public override string ConvertToOrdinal(int number)
}
}

if (word[word.Length - 1] == 't')
if (word[^1] == 't')
{
word = word.Substring(0, word.Length - 1) + 'd';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ static string Convert(long input, GrammaticalGender gender, bool isOrdinal, bool
}

if (isOrdinal && !string.IsNullOrWhiteSpace(lastOrdinalSubstitution))
parts[parts.Count - 1] = lastOrdinalSubstitution;
parts[^1] = lastOrdinalSubstitution;

return string.Join(" ", parts);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public override string Convert(long number)
public override string ConvertToOrdinal(int number)
{
var word = Convert(number);
return $"{word}{(IsVowel(word[word.Length - 1]) ? "یەم" : "ەم")}";
return $"{word}{(IsVowel(word[^1]) ? "یەم" : "ەم")}";
}

static bool IsVowel(char c) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ string Convert(long number, bool isOrdinal, bool addAnd = true)
}
else if (isOrdinal)
{
parts[parts.Count - 1] += "th";
parts[^1] += "th";
}

var toWords = string.Join(" ", parts);
Expand Down

0 comments on commit 9ebca0d

Please sign in to comment.