code
def c=(foo) p "hello" return foo + 1 end p self.c = 3 d = (self.c = 3) pd
and it will print only 3 ... in other words, the return value of 4 is not assigned to d , why?
d
Setters return their argument (or the right operand, depending on how you look at it) - always.
Methods like def foo=(bar) cannot return a value. Probably to enable multitasking:
def foo=(bar)
a = self.foo = 3 # a will be 3, independent of what foo returns
Source: https://habr.com/ru/post/1341228/More articles:Is git ls-files characteristic agnostic? If not, then what? - gitExcel: get cell color - excelJavadoc metadata storage time? - javaIs the Boost library a weighted median broken? - c ++MS Visual Studio for Linux - compilation and debugging in VirtualBox - c ++Algorithm for obtaining all possible subsets of a list in the order of their product without creating and sorting the entire list (for example, generators) - pythontransfer information from the service on which the foreground operation is performed - androidWhy are breakpoints invisible in Matlab editor windows? - debugginghttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1341232/moving-js-files-to-a-cdn-how-to-manage-ajax-requests&usg=ALkJrhh37jf4Pa6YtLPqu6pwZ2v2YR4qOQEnd a for loop by pressing 'q' - javaAll Articles