do y end (ciertamente me recuerdan PASCAL), o en una sola linea { y }, esto es lo que llamamos convencionalmente bloques (de instrucciones).# método de configuración config :scope, do |bag| bag.set :key, 'value' end
Nada nuevo, tampoco para aburrirse, lo bonito de este lenguaje es la manera en que maneja estos conceptos de bloques. Pero también tiene una sintaxis poderosa, breve y bastante agradable de leer y escribir.
¿Hago mal en preferir un lenguaje también por su estética?
Tampoco voy a dar una clase de bloques en ruby, pero me interesa en concreto el concepto de
lambda y su utilización como callback en algunos escenarios cotidianos en los lenguajes de programación de alto nivel como lo es también PHP.Y no hay que buscar demasiado, la versión mas reciente del pre-procesador de hipertexto ya venía con torta bajo el brazo, pues ofrece bastante potencial en la orientación a objetos así como con este bonito concepto que es un closure. De hecho, en php un closure por si mismo es un objeto, una clase.
// método de configuración
config('scope', function ($bag) {
$bag->set('key', 'value');
});
Finalmente me parece que su funcionalidad es la misma, contener un grupo de instrucciones en un contexto aislado, sin importar si devuelve un resultado o no.
Así como el ejemplo de un método de configuración cualquiera se pueden dar otras alternativas mas flexibles, aquí otra definición:
// agregamos un nuevo libro en alguna colección
function add_book_to($user, Closure $describe) {
$book = $user->books->build();
$describe($book);
$book->save();
}
// seleccionamos a un usuario
$me = user::first_by_name('Alvaro');
// agregamos el libro
add_book_to($me, function ($book) {
$book->title = 'Fake title';
$book->description = 'Fake description';
});
Y la verdad es que una función anónima implementada en php tiene bastantes desventajas a comparación de otros lenguajes, pero tampoco es inútil. Se pueden conseguir features interesantes en cuanto a flexibilidad en php.
Chiro-liro
10 comentarios:
Live cricket betting adds a new level of excitement compared to pre-match betting. With fairplay cricket live, users can:
• Analyze match momentum
• Adjust strategies during gameplay
• Hedge bets to reduce risk
• Take advantage of sudden odds changes
fairplay cricket live
Cricket fans look for stability and quick odds updates. From what I observed on Silver Exchange, the platform performs consistently well.
When performance meets smart design, engagement becomes effortless. Fairplay Club offers a fluid, responsive, and user-friendly experience.
A dependable platform makes online engagement much smoother. After checking Winbuzz Login, I liked how responsive and stable the overall system feels.
A smartly structured interface improves online reliability. After accessing radhe exchange login, the process remained steady.
A simple layout and clear guidance can make a betting website more useful, and 1Win reflects that idea well. The platform highlights practical information on deposits, withdrawals, sports betting access, and casino game options without overcomplicating the experience. Users who want a Cricket ID can also find direct support-style details that make the starting process easier. This organized approach is helpful for people who prefer clear steps and everyday usability from the beginning.
For many visitors, a betting website becomes more useful when it explains access and account details without confusion, and Fair Deal follows that approach. The site offers information about cricket id use, deposits, withdrawals, sports betting, and casino games in a clear format. This helps users feel more comfortable while reviewing what they need before getting started. Those looking for simple and accessible Cricket ID information may find the platform a reliable place to check helpful updates and guidance.
A clear and organized website can make a big difference for betting users, and Winbuzz offers that kind of practical experience. The platform gives readers simple guidance on deposits, withdrawals, and access to sports betting and casino sections. It also provides useful direction for anyone interested in getting a Cricket ID through a more understandable process. With its direct tone and easy navigation, the site works well for users who want efficient access to essential information.
Big Daddy Game helps users who want quick understanding of betting features without unnecessary complexity. The website highlights useful areas such as account login, deposit and withdrawal details, and access to casino and sports betting options. It is particularly relevant for visitors interested in cricket-related betting support and simple user guidance. Those searching for Big Daddy Game Login can also view practical information about getting a Cricket ID for day-to-day cricket betting participation and smoother entry into the platform.
Big Daddy Game presents account access information in a simple way for users who want cricket id details, sports betting guidance, and casino game updates. Through big daddy login, visitors can reach the platform and check deposit or withdrawal-related information clearly. The website keeps navigation practical and easy to follow. For users looking to continue with cricket id access, big daddy game login gives a direct and useful path.
Publicar un comentario