Skip to content

Instantly share code, notes, and snippets.

@joshavant
Created December 3, 2014 07:53
Show Gist options
  • Save joshavant/42978514874ae96b02a7 to your computer and use it in GitHub Desktop.
Save joshavant/42978514874ae96b02a7 to your computer and use it in GitHub Desktop.
isHyperlink = category == current_page_category && !sublevel_of_work_category?(current_page.destination_path) ? false : true
DOESN'T SEEM TO BE FUNCTIONALLY EQUIVALENT TO
isHyperlink = category == current_page_category && sublevel_of_work_category?(current_page.destination_path)
...any thoughts why?
@bkutil
Copy link

bkutil commented Dec 3, 2014

They do not seem to be logically equivalent:

#!/usr/bin/env ruby

def tbl
  [false, true].each do |x|
    [false, true].each do |y|
      [false, true].each do |b|
        yield x, y, b
    end
  end
end
end

tbl do |x, y, b|
    a  = (b == (x && !y) ? false : true)
    puts "a: #{a} b: #{b} x: #{x} y: #{y}"
end

puts

tbl do |x, y, b|
  a = (b == (x && y))
  puts "a: #{a} b: #{b} x: #{x} y: #{y}"
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment