From: non.dmitriy@... Date: 2019-11-12T19:05:29+00:00 Subject: [ruby-core:95820] [Ruby master Feature#16341] Proposal: Set#to_proc Issue #16341 has been updated by Nondv (Dmitry Non). Speaking of hashes, they could implement implicit proc conversion as well: ```ruby class Hash def to_proc ->(key) { self[key] } end end dogs = ['Lucky', 'Trimp', 'Lady'] favourite_food = { 'Lucky' => 'salmon', 'Trimp' => 'pasta', 'Lady' => 'pasta' } food_to_order = dogs.map(&favourite_food) ``` ---------------------------------------- Feature #16341: Proposal: Set#to_proc https://bugs.ruby-lang.org/issues/16341#change-82647 * Author: Nondv (Dmitry Non) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- ``` ruby class Set def to_proc -> (x) { include?(x) } # or method(:include?).to_proc end end ``` Usage: ```ruby require 'set' banned_numbers = Set[0, 5, 7, 9] (1..10).reject(&banned_numbers) # ===> [1, 2, 3, 4, 6, 8, 10] ``` -- https://bugs.ruby-lang.org/ Unsubscribe: