Issue #4824 has been updated by dsferreira (Daniel Ferreira).


graywolf (Gray Wolf) wrote:

> So Kernel#executable? tells me that something is able to be executed, not that
it was in fact executed.

Correct, `Kernel#executable?` infers if the code is able to be executed.

Usually when we use

```ruby
if __FILE__ == $0
  # call code to be run
  main(ARGV)
end
```

We are saying that the code should only be executed if the condition applies.

The code will be executed once we call `main(ARGV)`.
The code is able to be executed if `__FILE__ == $0`.


----------------------------------------
Feature #4824: Provide method Kernel#executed?
https://bugs.ruby-lang.org/issues/4824#change-70777

* Author: lazaridis.com (Lazaridis Ilias)
* Status: Assigned
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 
----------------------------------------
The current construct to execute main code looks not very elegant:

~~~ruby
if __FILE__ == $0
  my_main()          # call any method or execute any code
end
~~~

With a `Kernel#executed?` method, this would become more elegant:

~~~ruby
if executed?
  #do this
  #do that
  my_main()
end
~~~

or

~~~ruby
main() if executed?
~~~

This addition would not break any existent behaviour.




-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>