Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
## original (broken) code var ReadHash = Class.create(); ReadHash.prototyte = { initialize: function(data){ this.data=data; }, read: function(){ this.data.each(function(pair) { alert(pair.key + ' = "' + pair.value + '"'); }); } }; var ReadMyData = Class.create(); ReadMyData.prototype = Object.extend(new ReadHash(),{ initialize: function(data){ this.data=data; } }); var TestReadHash = new ReadMyData($H({ var1: 'foo1', var2: 'foo2' })); TestReadHash.read(); ## rewritten for Prototype 1.6 and later var ReadHash = Class.create({ initialize: function(data){ this.data = data; }, read: function(){ this.data.each(function(pair) { alert(pair.key + ' = "' + pair.value + '"'); }); } }); var ReadMyData = Class.create(ReadHash, { initialize: function(data){ this.data=data; } }); var TestReadHash = new ReadMyData($H({ var1: 'foo1', var2: 'foo2' })); TestReadHash.read(); ## ... still, this is how the pros to it var hash = $H({ foo:1, bar:2 }) alert(hash.inspect())
This paste will be private.
From the Design Piracy series on my blog: