What is a closure?
How do we implement/create/use a closure in Ruby?
What's the difference between a closure in JS vs Ruby?
Why do we use closures so much more in JS as opposed to Ruby?
What is the Ruby analog of an anonymous function in Javascript?
| =Navigating= | |
| visit('/projects') | |
| visit(post_comments_path(post)) | |
| =Clicking links and buttons= | |
| click_link('id-of-link') | |
| click_link('Link Text') | |
| click_button('Save') | |
| click('Link Text') # Click either a link or a button | |
| click('Button Value') |
| #!/usr/bin/env ruby | |
| class Solver | |
| B = " " | |
| attr_reader :sudoku_board | |
| def initialize | |
| @sudoku_board = [[B, 4, B, B, B, 5, B, 1, B], | |
| [B, B, B, B, 1, B, 6, B, 9], | |
| [6, B, 1, 9, 3, B, B, B, 4], |
| require 'nokogiri' | |
| require 'open-uri' | |
| url = "http://www.gutenberg.org/files/2701/2701-h/2701-h.htm" | |
| doc = Nokogiri::HTML(open(url)) | |
| words = doc.text.downcase | |
| .gsub(/[^\w\s]/,'') # remove non word or space characters | |
| .gsub(/\n/,' ') # remove new lines | |
| .gsub(/\s+/,' ') # normalize spaces (only one space ever) | |
| .split("chapter one").first # remove preamble |
| // iOS Media Queries | |
| // Goal: capture styles for iPhone, iPhone 3G, iPhone 3GS, iPhone 4, iPhone 4S, iPad, and iPad 2 | |
| // | |
| // Author: Tony Schneider (@tonywok) | |
| // Please tell me where I fail. :) | |
| // iPhone v(4,4S) portrait | |
| // test: black text (overwritten by v* portrait) with blue background | |
| @media all and (-webkit-min-device-pixel-ratio: 2) and (orientation: portrait) { | |
| a { |
What is a closure?
How do we implement/create/use a closure in Ruby?
What's the difference between a closure in JS vs Ruby?
Why do we use closures so much more in JS as opposed to Ruby?
What is the Ruby analog of an anonymous function in Javascript?