/explore

Click through on any links that interest you or select the planets on the right to continue exploring the Outer Web.
You are here

ryanbigg.com
| | grosser.it

Diff is defined on Set, but not on Array, so we patch it in... (thanks to reto) Usage [1,2] ^ [2,3,4] == [1,3,4] Code class Array def ^(other) result = dup other.each{|e| result.include?(e) result.delete(e) : result.push(e) } result end unless method_defined?(:^) alias diff ^ unless method_defined?(:diff) end puts ([] ^ [1]).inspect # [1] puts...
5.8 parsecs

Travel
| |
| | qsantos.fr

This article will quickly explain the Rust types [T; N], &[T; N], &[T], Vec, &Vec with C code, and what the str, &str, String, OsString and CString add. Arrays and Slices Rust C [T; N] (array)Example: [i32; 100]Allocated on the stack T[N]Example: int[100]Allocated on the stack &[T; N] (array reference)Example: &[i32; 100]N is tracked at ... Continue reading Rust Strings for C Programmers
6.8 parsecs

Travel
| |
| | thomascountz.com

Modelable Yesterday, we left off with module, Modelable, that, when included, adds two class methods, .link_to(), and .columns(). module Modelable def self.included(base) base.extend(ClassMethods) end module ClassMethods def link_to(table_name) @table_name = table_name.to_s end def columns SQLite3::Database.new("books_app") .execute("PRAGMA table_info(#{@table_name})") .map { |column| column[1].to_sym } end end end We use this module like this: class Book include Modelable link_to(:books) end Book.columns #=> [:id, :title, :author, :isbn] Notice, that if we don't call the .link_to() method, we would get an error: class Book include Modelable end Book.columns #=> SQLite3::SQLException: near ")": syntax error Because we haven't defined the @table_name class in...
5.9 parsecs

Travel
| |
| | juandebravo.com

Juan de Bravo - Personal thoughts about technology (@juandebravo)
17.9 parsecs

Travel
|