What returns that method?

Hello list,

because i'm trying to make my code documentation better, i would like to
know a thing.

I have that method:

def self.my_method
  system('xelatex cv_10.tex')
  system('biber cv_10.bcf')
  system('xelatex cv_10.tex')
end

What returns a method in the case (like that) that aren't defined a
returning value.

Greetings
Sascha

···

--
Yours sincerly
Sascha Manns

Maifeldstraße 10
56727 Mayen
Phone: +49-1573-9242730
Email: Sascha.Manns@directbox.com
Web: http://saigkill.github.io
Jabber: saigkill@jabber.org
GPG: hkp://keys.gnupg.net

Ruby has implicit returns, so it's the value of whatever the last evaluated
expression is. In this case, it'll be the return value of the last system
call.

···

On Sat, Oct 3, 2015 at 9:30 AM, Sascha Manns <Sascha.Manns@directbox.com> wrote:

Hello list,

because i'm trying to make my code documentation better, i would like to
know a thing.

I have that method:

def self.my_method
  system('xelatex cv_10.tex')
  system('biber cv_10.bcf')
  system('xelatex cv_10.tex')
end

What returns a method in the case (like that) that aren't defined a
returning value.

Greetings
Sascha

--
Yours sincerly
Sascha Manns

Maifeldstraße 10
56727 Mayen
Phone: +49-1573-9242730
Email: Sascha.Manns@directbox.com
Web: http://saigkill.github.io
Jabber: saigkill@jabber.org
GPG: hkp://keys.gnupg.net

--
*Kevin D. Deisz*
DrugDev TrialNetworks
Senior Software Engineer

I'm not quite sure what you're trying to ask. Do you mean, "what does
a method return, if it doesn't use the 'return' keyword"? ("Returning
a method" is also possible, but a very advanced topic.)

It returns the value of its last expression evaluated. The "return"
keyword is optional in these cases, and rarely used. So, for
instance:

  def add(a, b)
    puts "Adding #{a} and #{b}"
    a + b
  end

is the same as:

  def add(a, b)
    puts "Adding #{a} and #{b}"
    return a + b
  end

and would have the same result (though different printed output) as:

  def add(a, b)
    c = a + b
    puts "Adding #{a} and #{b}; got #{c}"
    c # we could also do "return c" here
  end

-Dave

···

On Sat, Oct 3, 2015 at 9:30 AM, Sascha Manns <Sascha.Manns@directbox.com> wrote:

What returns a method in the case (like that) that aren't defined a
returning value.

--
Dave Aronson, consulting software developer of Codosaur.us,
PullRequestRoulette.com, Blog.Codosaur.us, and Dare2XL.com.

Ammendind the others. ...
To know what Kernel#system returns (as it is the last expression of your
method) look at Module: Kernel (Ruby 2.2.0)

···

Em Sáb, 3 de out de 2015 10:49, Dave Aronson < ruby-talk.list.2.TRex@codosaur.us> escreveu:

On Sat, Oct 3, 2015 at 9:30 AM, Sascha Manns <Sascha.Manns@directbox.com> > wrote:

> What returns a method in the case (like that) that aren't defined a
> returning value.

I'm not quite sure what you're trying to ask. Do you mean, "what does
a method return, if it doesn't use the 'return' keyword"? ("Returning
a method" is also possible, but a very advanced topic.)

It returns the value of its last expression evaluated. The "return"
keyword is optional in these cases, and rarely used. So, for
instance:

  def add(a, b)
    puts "Adding #{a} and #{b}"
    a + b
  end

is the same as:

  def add(a, b)
    puts "Adding #{a} and #{b}"
    return a + b
  end

and would have the same result (though different printed output) as:

  def add(a, b)
    c = a + b
    puts "Adding #{a} and #{b}; got #{c}"
    c # we could also do "return c" here
  end

-Dave

--
Dave Aronson, consulting software developer of Codosaur.us,
PullRequestRoulette.com, Blog.Codosaur.us, and Dare2XL.com.

System method returns 0 or not (in the case if there' re errors or not).
But if you received that there're not errors in system call, there're not
any guaranties that system processed your shell command successfully.

···

03 окт. 2015 г. 16:30 пользователь "Sascha Manns" < Sascha.Manns@directbox.com> написал:

Hello list,

because i'm trying to make my code documentation better, i would like to
know a thing.

I have that method:

def self.my_method
  system('xelatex cv_10.tex')
  system('biber cv_10.bcf')
  system('xelatex cv_10.tex')
end

What returns a method in the case (like that) that aren't defined a
returning value.

Greetings
Sascha

--
Yours sincerly
Sascha Manns

Maifeldstraße 10
56727 Mayen
Phone: +49-1573-9242730
Email: Sascha.Manns@directbox.com
Web: http://saigkill.github.io
Jabber: saigkill@jabber.org
GPG: hkp://keys.gnupg.net

Hello Alexey and all others,

thank you very much for helping me to clarify that point. Now i can
write better code documentations :slight_smile:

Greetings
Sascha

···

Am 04.10.2015 um 11:57 schrieb Alexey Bovanenko:

System method returns 0 or not (in the case if there' re errors or
not). But if you received that there're not errors in system call,
there're not any guaranties that system processed your shell command
successfully.

03 окт. 2015 г. 16:30 пользователь "Sascha Manns" > <Sascha.Manns@directbox.com <mailto:Sascha.Manns@directbox.com>> написал:

    Hello list,

    because i'm trying to make my code documentation better, i would
    like to know a thing.

    I have that method:

    def self.my_method
      system('xelatex cv_10.tex')
      system('biber cv_10.bcf')
      system('xelatex cv_10.tex')
    end

    What returns a method in the case (like that) that aren't defined
    a returning value.

    Greetings
    Sascha

    --
    Yours sincerly
    Sascha Manns

    Maifeldstraße 10
    56727 Mayen
    Phone: +49-1573-9242730 <tel:%2B49-1573-9242730>
    Email: Sascha.Manns@directbox.com <mailto:Sascha.Manns@directbox.com>
    Web: http://saigkill.github.io
    Jabber: saigkill@jabber.org <mailto:saigkill@jabber.org>
    GPG: hkp://keys.gnupg.net <http://keys.gnupg.net>

--
Yours sincerly
Sascha Manns

Maifeldstraße 10
56727 Mayen
Phone: +49-1573-9242730
Email: Sascha.Manns@directbox.com
Web: http://saigkill.github.io
Jabber: saigkill@jabber.org
GPG: hkp://keys.gnupg.net

Hi Alexey,

Perhaps you've mistaken the return values of Kernel#system.

  system 'ls'

=> true

system 'ls non-existent-file' # It would give an error from the 'ls' itself

ls: non-existent-file: No such file or directory
=> false

system 'nonexistentshellcommand' # It would give an error from the shell

=> nil

Look, true, false and nil. Those are the returning values of system.
(No 0 (zero) returned).

Abinoam Jr.

···

On Sun, Oct 4, 2015 at 9:41 AM, Sascha Manns <Sascha.Manns@directbox.com> wrote:

Hello Alexey and all others,

thank you very much for helping me to clarify that point. Now i can write
better code documentations :slight_smile:

Greetings
Sascha

Am 04.10.2015 um 11:57 schrieb Alexey Bovanenko:

System method returns 0 or not (in the case if there' re errors or not). But
if you received that there're not errors in system call, there're not any
guaranties that system processed your shell command successfully.

03 окт. 2015 г. 16:30 пользователь "Sascha Manns" > <Sascha.Manns@directbox.com> написал:

Hello list,

because i'm trying to make my code documentation better, i would like to
know a thing.

I have that method:

def self.my_method
  system('xelatex cv_10.tex')
  system('biber cv_10.bcf')
  system('xelatex cv_10.tex')
end

What returns a method in the case (like that) that aren't defined a
returning value.

Greetings
Sascha

--
Yours sincerly
Sascha Manns

Maifeldstraße 10
56727 Mayen
Phone: +49-1573-9242730
Email: Sascha.Manns@directbox.com
Web: http://saigkill.github.io
Jabber: saigkill@jabber.org
GPG: hkp://keys.gnupg.net

--
Yours sincerly
Sascha Manns

Maifeldstraße 10
56727 Mayen
Phone: +49-1573-9242730
Email: Sascha.Manns@directbox.com
Web: http://saigkill.github.io
Jabber: saigkill@jabber.org
GPG: hkp://keys.gnupg.net