@anonymous/

SilverCalculatingSorting

Ruby

No description

fork
loading
Files
  • main.rb

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.48906610468022294","path":"main.rb","file":{"path":"main.rb","content":{"asEncoding":{"base64":"Y2xhc3MgT2JqZWN0CiAgICBkZWYgc2VsZi5hbGwKICAgICAgICBPYmplY3RTcGFjZS5lYWNoX29iamVjdChzZWxmKS50b19hCiAgICBlbmQKZW5kCgpjbGFzcyBNYW4KICBhdHRyX2FjY2Vzc29yIDptb3J0YWwsIDpuYW1lCiAgZGVmIGluaXRpYWxpemUobmFtZSkKICAgIEBuYW1lID0gbmFtZSAjIElNUExJQ0lUTFk6IEFsbCBtZW4gaGF2ZSBhIG5hbWUKICAgIEBtb3J0YWwgPSB0cnVlICMgRVhQTElDSVRMWTogQWxsIG1lbiBhcmUgbW9ydGFsCiAgZW5kCmVuZAoKIyBMZXRzIGNyZWF0ZSBzb21lIG1lbgoKTWFuLm5ldygnVGltZVNlZWtlcicpCk1hbi5uZXcoJ2phY29iYnJvd25hY3JvJykKTWFuLm5ldygnU29jcmF0ZXMnKQoKcHV0cyAiSG93IG1hbnkgbWVuIGFyZSB0aGVyZT8iCnB1dHMgTWFuLmFsbC5jb3VudAoKcHV0cyAiQXJlIGFsbCBtZW4gbW9ydGFsPyIKcHV0cyBNYW4uYWxsLmZpbmQgeyB8bWFufCBub3QgbWFuLm1vcnRhbCB9Lm5pbD8gIyBMb29rIGZvciBmYWxzaWZpZXIuIEFueSBpbW1vcnRhbCBtYW4gbWVhbnMgdGhlIGFuc3dlciBpcyAnTm8nCgpwdXRzICdJcyBTb2NyYXRlcyBtb3J0YWw/JwpwdXRzIE1hbi5hbGwuZmluZCB7IHxtYW58IG1hbi5uYW1lID09ICJTb2NyYXRlcyIgfS5tb3J0YWwKCiMgTm93IGxldHMgZG8gc29tZXRoaW5nIHNseS4gQmVjYXVzZSB3ZSBhcmUgR29kIC0gd2UgY2FuIG1ha2UgU29jcmF0ZXMgaW1tb3J0YWwhCnB1dHMgIkFuZCBHb2Qgc2FpZDogTGV0IFNvY3JhdGVzIGJlIGltbW9ydGFsISAqKndhdmVzIG1hZ2ljIHdhbmQqKiIKTWFuLmFsbC5maW5kIHsgfG1hbnwgbWFuLm5hbWUgPT0gIlNvY3JhdGVzIiB9Lm1vcnRhbD1mYWxzZQoKcHV0cyAiQXJlIGFsbCBtZW4gbW9ydGFsPyIKcHV0cyBNYW4uYWxsLmZpbmQgeyB8bWFufCBub3QgbWFuLm1vcnRhbCB9Lm5pbD8gCgpwdXRzICdJcyBTb2NyYXRlcyBtb3J0YWw/JwpwdXRzIE1hbi5hbGwuc2VsZWN0IHsgfG1hbnwgbWFuLm5hbWUgPT0gIlNvY3JhdGVzIiB9LmZpbmQgeyB8bWFufCBub3QgbWFuLm1vcnRhbCB9Lm5pbD8KCnB1dHMgIkFyZSBhbGwgbWVuIE5PVCBuYW1lZCBTb2NyYXRlcyBtb3J0YWw/IgpwdXRzIE1hbi5hbGwuc2VsZWN0IHsgfG1hbnwgbWFuLm5hbWUgIT0gIlNvY3JhdGVzIiB9LmZpbmQgeyB8bWFufCBub3QgbWFuLm1vcnRhbCB9Lm5pbD8K"},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
class Object
    def self.all
        ObjectSpace.each_object(self).to_a
    end
end

class Man
  attr_accessor :mortal, :name
  def initialize(name)
    @name = name # IMPLICITLY: All men have a name
    @mortal = true # EXPLICITLY: All men are mortal
  end
end

# Lets create some men

Man.new('TimeSeeker')
Man.new('jacobbrownacro')
Man.new('Socrates')

puts "How many men are there?"
puts Man.all.count

puts "Are all men mortal?"
puts Man.all.find { |man| not man.mortal }.nil? # Look for falsifier. Any immortal man means the answer is 'No'

puts 'Is Socrates mortal?'
puts Man.all.find { |man| man.name == "Socrates" }.mortal

# Now lets do something sly. Because we are God - we can make Socrates immortal!
puts "And God said: Let Socrates be immortal! **waves magic wand**"
Man.all.find { |man| man.name == "Socrates" }.mortal=false

puts "Are all men mortal?"
puts Man.all.find { |man| not man.mortal }.nil? 

puts 'Is Socrates mortal?'
puts Man.all.select { |man| man.name == "Socrates" }.find { |man| not man.mortal }.nil?

puts "Are all men NOT named Socrates mortal?"
puts Man.all.select { |man| man.name != "Socrates" }.find { |man| not man.mortal }.nil?
ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux]