Talk:First-class function: Difference between revisions

Content deleted Content added
Dcoetzee (talk | contribs)
Line 44:
 
: I must concur. [[User:Jsnx|jsnx]] ([[User talk:Jsnx|talk]]) 02:11, 7 December 2007 (UTC)
 
----
 
: However you can access them by calling their containing module and asking for the function. Like:
<code>
def f(x) # global functions are contained in the Kernel
x + 4
end
g = Kernel.method :f
g.call(2) #=> 6
g[2] #=> 6
g.(2) #=> 6 (only works in ruby, its a new syntax)
g.class #=> 'Method'
proc = g.to_proc # returns the method as a Proc
</code>
: Also, in Ruby, a Proc is by definition exactly what a first class function is. Granted, you can't directly assign a method to a variable using the = operator like in other languages, I would still argue that Ruby does indeed have first class functions.
: [[Special:Contributions/75.143.82.88|75.143.82.88]] ([[User talk:75.143.82.88|talk]]) 03:07, 3 August 2009 (UTC)
 
== Function literals in Python ==