Ruby意外的$ end,期待keyword_end

时间:2013-12-26 02:50:05

标签: ruby

我的代码中出现以下错误。

  

ruby​​ -w search.rub search.rub:19:警告:'end'与'case'不匹配的缩进12在search.rub:62:语法错误,意外$ end,期待keyword_end

我觉得它与所有目的有关。

#!/usr/bin/ruby

num_line = 0
NumDiccionario = 1

def checkPassword (pass)
  print pass, "\t"
  system("bitcoind", "walletpassphrase", pass, "20")
  case $?.exitstatus
  when 0
    puts "You found it!#{pass}"
    File.open('password.txt', 'w') do |file|
      file.puts phrase + "\n"
    end
  exit 0
end

str_num_line = "0"

File.open('lastLine.txt', 'r') do |file2|
  str_num_line = file2.gets
end 

if (str_num_line.to_i > 0 )
  print "Last searching stopped at line " + str_num_line + "\n"
  STDOUT.flush
  print "Continue from here? y/n:" 
  resp = gets.chomp
  if (resp == "y")
    num_line =str_num_line.to_i
  end
end

1 个答案:

答案 0 :(得分:1)

def checkPassword (pass)
  print pass, "\t"
  system("bitcoind", "walletpassphrase", pass, "20")
  case $?.exitstatus
  when 0
    puts "You found it!#{pass}"
    File.open('password.txt', 'w') do |file|
      file.puts phrase + "\n"
    end
  end
  exit 0
end