Skip to main content
added 22 characters in body
Source Link
tokland
  • 11.1k
  • 1
  • 20
  • 25

Notes:

  • Use functional Enumerable#map instead of imperative pattern "obj = []"obj = [] + Enumerable#each + Array#<<.
  • Use Kernel#Hash to build a hash from its pairs. However,Note that this method is very ugly, if and some prefer a more OOP approach use, in that case check Enumerable#mash from Facets.
  • Use nokogiri_node.text.
  • Arguments in blocks can be unpacked.

I'd write:

require 'nokogiri'
require 'facets'

def get_training_queue(xml_data)
  xml_data.xpath("//row").map do |skill_in_queue|
    skill_in_queue.attributes.mash do |name, attribute|
      [name.to_sym, attribute.text]
    end
  end
end

All those eachs and in-place updates show that you think in imperative terms instead of functional, check this wiki page.

Notes:

  • Use functional Enumerable#map instead of imperative pattern "obj = []" + Enumerable#each + Array#<<.
  • Use Kernel#Hash to build a hash from its pairs. However, this method is very ugly, if prefer a more OOP approach use Enumerable#mash from Facets.
  • Use nokogiri_node.text.
  • Arguments in blocks can be unpacked.

I'd write:

require 'nokogiri'
require 'facets'

def get_training_queue(xml_data)
  xml_data.xpath("//row").map do |skill_in_queue|
    skill_in_queue.attributes.mash do |name, attribute|
      [name.to_sym, attribute.text]
    end
  end
end

All those eachs and in-place updates show that you think in imperative terms instead of functional, check this wiki page.

Notes:

  • Use functional Enumerable#map instead of imperative pattern obj = [] + Enumerable#each + Array#<<.
  • Use Kernel#Hash to build a hash from its pairs. Note that this method is very ugly and some prefer a more OOP approach, in that case check Enumerable#mash from Facets.
  • Use nokogiri_node.text.
  • Arguments in blocks can be unpacked.

I'd write:

require 'nokogiri'
require 'facets'

def get_training_queue(xml_data)
  xml_data.xpath("//row").map do |skill_in_queue|
    skill_in_queue.attributes.mash do |name, attribute|
      [name.to_sym, attribute.text]
    end
  end
end

All those eachs and in-place updates show that you think in imperative terms instead of functional, check this wiki page.

added 56 characters in body
Source Link
tokland
  • 11.1k
  • 1
  • 20
  • 25

Notes:

  • Use functional Enumerable#map instead of imperative pattern "obj = []" + Enumerable#each + Array#<<.
  • Use Kernel#Hash to build a hash from its pairs. IHowever, this method is very ugly, if prefer a more OOP approach so I'd use Enumerable#mash from Facets.
  • Use nokogiri_node.text.
  • You can (and should) unpack valuesArguments in block argumentsblocks can be unpacked.

I'd write:

require 'nokogiri'
require 'facets'

def get_training_queue(xml_data)
  xml_data.xpath("//row").map do |skill_in_queue|
    skill_in_queue.attributes.mash do |name, attribute|
      [name.to_sym, attribute.text]
    end
  end
end

All those eachs and in-place updates show that you think in imperative terms instead of functional, check this wiki page.

Notes:

  • Use Enumerable#map instead of Enumerable#each + Array#<<.
  • Use Kernel#Hash to build a hash from its pairs. I prefer a more OOP approach so I'd use Enumerable#mash from Facets.
  • Use nokogiri_node.text.
  • You can (and should) unpack values in block arguments.

I'd write:

require 'nokogiri'
require 'facets'

def get_training_queue(xml_data)
  xml_data.xpath("//row").map do |skill_in_queue|
    skill_in_queue.attributes.mash do |name, attribute|
      [name.to_sym, attribute.text]
    end
  end
end

All those each and in-place updates show that you think in imperative terms instead of functional, check this wiki page.

Notes:

  • Use functional Enumerable#map instead of imperative pattern "obj = []" + Enumerable#each + Array#<<.
  • Use Kernel#Hash to build a hash from its pairs. However, this method is very ugly, if prefer a more OOP approach use Enumerable#mash from Facets.
  • Use nokogiri_node.text.
  • Arguments in blocks can be unpacked.

I'd write:

require 'nokogiri'
require 'facets'

def get_training_queue(xml_data)
  xml_data.xpath("//row").map do |skill_in_queue|
    skill_in_queue.attributes.mash do |name, attribute|
      [name.to_sym, attribute.text]
    end
  end
end

All those eachs and in-place updates show that you think in imperative terms instead of functional, check this wiki page.

added 36 characters in body
Source Link
tokland
  • 11.1k
  • 1
  • 20
  • 25

Notes:

  • Use Enumerable#map instead of Enumerable#each + Array#<<.
  • Use Kernel#Hash to build a hash from its pairs. I prefer a more OOP approach so I II'd use Enumerable#mash from Facets.
  • Use nokogiri_node.text.
  • All thoseYou can each and in-place updates show that you think(and should) unpack values in imperative terms instead of functional, check this wiki pageblock arguments.

I'd write:

require 'nokogiri'
require 'facets'

def get_training_queue(xml_data)
  xml_data.xpath("//row").map do |skill_in_queue|
    skill_in_queue.attributes.mash do |name, attribute|
      [name.to_sym, attribute.text]
    end
  end
end

All those each and in-place updates show that you think in imperative terms instead of functional, check this wiki page.

Notes:

  • Use Enumerable#map instead of Enumerable#each.
  • Use Kernel#Hash to build a hash from pairs. I prefer a more OOP approach so I I use Enumerable#mash from Facets.
  • Use nokogiri_node.text.
  • All those each and in-place updates show that you think in imperative terms instead of functional, check this wiki page.

I'd write:

require 'nokogiri'
require 'facets'

def get_training_queue(xml_data)
  xml_data.xpath("//row").map do |skill_in_queue|
    skill_in_queue.attributes.mash do |name, attribute|
      [name.to_sym, attribute.text]
    end
  end
end

Notes:

  • Use Enumerable#map instead of Enumerable#each + Array#<<.
  • Use Kernel#Hash to build a hash from its pairs. I prefer a more OOP approach so I'd use Enumerable#mash from Facets.
  • Use nokogiri_node.text.
  • You can (and should) unpack values in block arguments.

I'd write:

require 'nokogiri'
require 'facets'

def get_training_queue(xml_data)
  xml_data.xpath("//row").map do |skill_in_queue|
    skill_in_queue.attributes.mash do |name, attribute|
      [name.to_sym, attribute.text]
    end
  end
end

All those each and in-place updates show that you think in imperative terms instead of functional, check this wiki page.

added 10 characters in body
Source Link
tokland
  • 11.1k
  • 1
  • 20
  • 25
Loading
added 8 characters in body
Source Link
tokland
  • 11.1k
  • 1
  • 20
  • 25
Loading
Source Link
tokland
  • 11.1k
  • 1
  • 20
  • 25
Loading