davidgf / design-patterns-in-ruby Goto Github PK
View Code? Open in Web Editor NEWGoF design patterns in Ruby
GoF design patterns in Ruby
https://github.com/davidgf/design-patterns-in-ruby/blob/master/iterator.md
class having <==> method should include comparable module
I've actually wanted to use a pattern like this in Ruby, where I've wanted an object to do some nonstandard behavior and then do some standard behavior. For example, an OpCode class that executes a certain operation argument then changes the value of the address in memory for a simple emulator, or a Spell class that checks if the Character casting it has enough magic_points to cast the spell, fails if it doesn't, subtracts mp_cost argument from the character casting it and executes the spell_formula argument.
The thing is, in Ruby I didn't create a special operation or spell_formula class to pass around a method / command as an argument. I used a lambda.
It would be nice if the description of this pattern was expanded to include the pros and cons of this method, since from my perspective it just seems like the natural and dare-I-say-it, ruby way to do things.
but this is a wonderful thing you have put together, thanks for doing it.
rgds
Ben
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.