Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Recent Updates (近況報告)

yhara
September 21, 2014

Recent Updates (近況報告)

2014/09/21 RubyHiroba2014

yhara

September 21, 2014
Tweet

More Decks by yhara

Other Decks in Programming

Transcript

  1. Attendees from Matsue office — @nacl — @yukihiro_matz — @shugomaeda

    — @takaokouji — @nobyuki — @nari3 — @yhara (me)
  2. My current project — github:yhara/boom — Toy language with type

    inference — Will resume it as soon as I quit Ingress
  3. Recent interests 1. "Ruby and Patten Match" 2. "Ideal way

    to map a hash" 3. "Opal the Ruby to JS compiler"
  4. Ruby HAS pattern match (via gem) — pattern-match gem (@k_tsj)

    — patm gem (@todesking, limited but faster) — egison gem (@__Egi, RubyKaigi Day 1)
  5. Match regexp against string ʮIf the string is like thisʯ

    str = "add 1 2" if str =~ /add (\d+) (\d+)/ puts "Add #{$1} and #{$2}" end
  6. Match pattern against array ʮIf the array is like thisʯ

    require 'pattern-match' ary = [:add, 1, 2] match(ary){ with(_[:add, x, y]){ puts "Add #{x} and #{y}" } }
  7. Match pattern against your class class Book # has :title,

    :price ... def self.deconstruct(val) accept_self_instance_only(val) return [val.title, val.price] end end book = Book.new("Programming Ruby", 3400) match(book){ with(Book.(/Ruby/, 0..5000)) { p book } }
  8. My proposals accepted — #1961 __dir__ — #4890 Enumerable#lazy —

    #6670 String#lines should return array and one more challenge:
  9. Current hash.map — How to convert {:a => 1, :b

    => 2} into {"a" => 1, "b" => 2} h = {:a => 1, :b => 2} pairs = h.map{|k, v| [k.to_s, v] } #=> [["a", 1], ["b", 2]]
  10. Hash#[] h = {a: 1, b: 2} pairs = h.map{|k,

    v| [k.to_s, v] } #=> [["a", 1], ["b", 2]] Hash[pairs] #=> {"a" => 1, "b" => 2}
  11. Enumerable#to_h (Ruby >= 2.1) h = {a: 1, b: 2}

    pairs = h.map{|k, v| [k.to_s, v] } #=> [["a", 1], ["b", 2]] pairs.to_h #=> {"a" => 1, "b" => 2}
  12. Ideal way h = {a: 1, b: 2} h.xxxxxx{|k, v|

    [k.to_s, v] } #=> {"a" => 1, "b" => 2} xxxxxx == hash_map, map_hash, hash_by, morph, apply, map_kv, ...???
  13. Join bugs.ruby-lang.org — Feature #10208: Passing block to Enumerable#to_h —

    Feature #6669: A method like Hash#map but returns hash We need a good name :-( Any ideas?
  14. Why Opal matters #1 JavaScript x HTML5 JavaScript x WebSocket

    JavaScript x WebRTC JavaScript x Mobile ...
  15. Why Opal matters #1 Ruby(Opal) x HTML5 Ruby(Opal) x WebSocket

    Ruby(Opal) x WebRTC Ruby(Opal) x Mobile ...
  16. One language for C/S — No context switch — Share

    logic among C/S (validation, etc.) — Pre-render view on the server side cf. Rendr, Meteor (Node.js)
  17. Related products Check it out! — For #1: github:yeahrb/yeah "Practical

    Ruby video game framework" — For #2: github:voltrb/volt "A ruby web framework where your ruby runs on both server and client"
  18. Yeahrb Demo $ gem i yeah $ yeah new hello

    $ cd hello $ yeah serve $ open http://localhost:1234 $ vi code/game.rb
  19. Yeahrb Demo code/game.rb: class Hello1 < Game def setup end

    def update(elapsed) display.fill_color = C[255,255,255] display.fill_rectangle(V[0,0], display.size) end end