The Great Coding Language Thread

Someone Else 37

Forum Addict
Feb 10, 2013
1,876
1,440
168
(println "lol")
(println "You forgot a quote.")
(println "The \"official?\" tutorial I find pretty meh... I think the one for Haskell I linked you a while back is much better. More fun to read, at least.")
 

Someone Else 37

Forum Addict
Feb 10, 2013
1,876
1,440
168
(println "This looks much better, thank you.")
(println "Cheatsheet looks handy, too. Haskell has Hoogle, which lets you search functions by name, package, or type signature.")
 

1SDAN

New Member
Jul 29, 2019
1,189
-15
0
Well, my problem was fixed. Apparently since functions are also variables, they can be passed as such between functions
 

trajing

New Member
Jul 29, 2019
3,091
-14
1
Although there are a ton of ways that this is alleviated, like with blocks/lambdas/procs, but still having first-class functions would be really nice
Technically, the order of succession is block/proc/lambda.
Blocks are just that - blocks of code.
Procs are blocks stored in variables. So technically a Proc is a function in a true FP language.
Lambdas are Procs, except with Procs extra arguments are set to nil, with Lambdas the argument count is checked and errors are raised if you call one with the wrong amount. In addition, Lambdas will simply return the object (well, reference) once called, while Procs will also have the parent method return the same thing as the Proc.
Altogether, if you're looking for a method stored in a variable, Lambdas are the way to go in Ruby.
EDIT: Fixed a typo; added a period.
 
Last edited:

Strikingwolf

New Member
Jul 29, 2019
3,709
-26
1
Technically, the order of succession is block/proc/lambda.
Blocks are just that - blocks of code.
Procs are blocks stored in variables. So technically a Proc is a function in a true FP language.
Lambdas are Procs, except with Procs extra arguments are set to nil, with Lambdas the argument count is checked and errors are raised if you call one with the wrong amount. In addition, Lambdas will simply return the object (well, reference) once called, while Procs will also have the parent method return the same thing as the Proc.
Altogether, if you're looking for a method stored in a variable, Lambdas are the way to go in Ruby.
EDIT: Fixed a typo; added a period.
actually method :method_name does it :p