Skip to content

Instantly share code, notes, and snippets.

View pawel2105's full-sized avatar

Pawel Janiak pawel2105

View GitHub Profile
headlines = ["one","two","three","flee"]
#enumerables have a method #to_phrase.rhyme_key which gives a key based on pronunciation.
So headlines.map(&:to_phrase.rhyme_key) => 1,2,3,3 (for example)
#Now I want to filter out all the strings that don't have rhyme_key counterparts,
essentially leaving ["three","flee"] in the convoluted example above. I tried the code below,
but that just stores the rhyme_key values in the headlines array which is useless to me because
the original string literals get replaced with the values. How do I check against the values via
the methods without replacing the original strings?