In this tutorial we will look at filtering out words with specific letters for practice.

Words beginning with ‘j’

The command words_beginning_with can be passed one or more letters. Here we pass the letter j for words beginning with j. beginning_with is an alias for words_beginning_with - either can be used.

  # letter_filtering.rb

require 'cw'

cw do
  name " 4 words beginning with 'j' (18 wpm)"
  shuffle
  beginning_with  'j'
  word_count       4
  wpm             18
end


Words beginning with ‘qu’

Here we filter words beginning with the letters qu (in that order).

  # letter_filtering_2.rb

require 'cw'

cw do
  name " 4 words beginning with 'qu' (18 wpm)"
  shuffle
  beginning_with  'qu'
  word_count       4
  wpm             18
  test_letters
end


Words ending with ‘ing’ (test_letters)

The command ending_with is hopefully self exlanatory. It is an alias for the command words_ending_with.

  # letter_filtering_3.rb

require 'cw'

cw do
  comment "4 words ending with 'ing' (15 WPM)"
  shuffle
  wpm                 18
  ending_with         'ing'
  number_of_words     4
  test_letters
end


Words including ‘ain’ (test_letters)

The command including can be used to select words that include the letter or letter sequence supplied.

  # letter_filtering_4.rb

require 'cw'

cw do
  comment "4 words containing 'ain' (15 WPM)"
  shuffle
  wpm                 18
  words_including    'ain'
  number_of_words     4
  test_letters
end