Extracts the block to a method and replaces its usage with a method reference.