惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

罗磊的独立博客
Cisco Talos Blog
Cisco Talos Blog
C
Check Point Blog
博客园_首页
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Martin Fowler
Martin Fowler
Recorded Future
Recorded Future
S
Security @ Cisco Blogs
L
LINUX DO - 最新话题
博客园 - 司徒正美
P
Privacy International News Feed
G
Google Developers Blog
I
Intezer
Hacker News - Newest:
Hacker News - Newest: "LLM"
博客园 - 聂微东
The GitHub Blog
The GitHub Blog
C
Cybersecurity and Infrastructure Security Agency CISA
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Scott Helme
Scott Helme
K
Kaspersky official blog
I
InfoQ
Y
Y Combinator Blog
T
The Blog of Author Tim Ferriss
Webroot Blog
Webroot Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
大猫的无限游戏
大猫的无限游戏
D
Docker
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
W
WeLiveSecurity
Microsoft Azure Blog
Microsoft Azure Blog
Spread Privacy
Spread Privacy
量子位
H
Hacker News: Front Page
Simon Willison's Weblog
Simon Willison's Weblog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
SecWiki News
SecWiki News
S
Security Affairs
Latest news
Latest news
人人都是产品经理
人人都是产品经理
C
CERT Recently Published Vulnerability Notes
S
Security Archives - TechRepublic
V
Visual Studio Blog
T
Troy Hunt's Blog
S
Secure Thoughts
F
Fortinet All Blogs
V
V2EX
The Register - Security
The Register - Security
J
Java Code Geeks
MongoDB | Blog
MongoDB | Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO

博客园 - slaughter

java api下载网站 国外好的软件测试网站 watir,ruby版本查看方法 - slaughter - 博客园 Watir隐藏IE运行的方法 Ruby对MS Access的操作 Eclipse下安装RDT (转)什么是Unicode?什么是UTF-8?(1) Ruby的库路径 - slaughter - 博客园 ruby下snmp-trap发包实例 - slaughter - 博客园 Ruby对于串口的设置实例 - slaughter - 博客园 职业选择(转) java读写文件(转) 在Java中操纵UDP(转) 在Java中使用UDP协议编程的相关类(转) 终于给宝宝确定了名字 RFT的对象识别技术 Ruby设置IE不可见 VC对EXCEL操作 Ruby转exe方法(转)
ruby编码中碰到的一个诡异问题 - slaughter - 博客园
slaughter · 2008-06-26 · via 博客园 - slaughter

发现用if进行多重嵌套时,总是报错,"syntax error, unexpected $end, expecting kEND ",但使用case后,正常通过,匪夷所思!

 原编码如下:
    while i <2 
       userSheet.Cells(i,2).Value="111";
       userSheet.Cells(i,3).Value="aaa";
       userSheet.Cells(i,4).Value="group";
       userSheet.Cells(i,5).Value="kk";
       userSheet.Cells(i,6).Value="女";
       userSheet.Cells(i,7).Value="aaa@163.net";
       userSheet.Cells(i,8).Value="身份证";
       userSheet.Cells(i,9).Value="123";
       userSheet.Cells(i,10).Value="小学";
       userSheet.Cells(i,11).Value="12345";
       userSheet.Cells(i,12).Value="123456";
       userSheet.Cells(i,13).Value="火星";
       userSheet.Cells(i,14).Value="12345678";
       j=j+1;
       i=i+1;       
        if i<10 then
         userSheet.Cells(i,1).Value="test"+"0000000"+j.to_s;
        else if i<100 then
          userSheet.Cells(i,1).Value="test"+"000000"+j.to_s;
        else if i<1000 then
           userSheet.Cells(i,1).Value="test"+"00000"+j.to_s;
        else i<10000
          userSheet.Cells(i,1).Value="test"+"0000"+j.to_s;
        end       
     end   


      

通过后的编码:

while i <22
    
       userSheet.Cells(i,2).Value="111";
       userSheet.Cells(i,3).Value="aaa";
       userSheet.Cells(i,4).Value="zqd-group";
       userSheet.Cells(i,5).Value="tt";
       userSheet.Cells(i,6).Value="女";
       userSheet.Cells(i,7).Value="aaa@163.net";
       userSheet.Cells(i,8).Value="身份证";
       userSheet.Cells(i,9).Value="123";
       userSheet.Cells(i,10).Value="小学";
       userSheet.Cells(i,11).Value="12345";
       userSheet.Cells(i,12).Value="123456";
       userSheet.Cells(i,13).Value="火星";
       userSheet.Cells(i,14).Value="12345678";
       j=j+1;
       i=i+1;
             case i
         when 1..9
            userSheet.Cells(i,1).Value="test"+"0000000"+j.to_s;
         when 10..99
          userSheet.Cells(i,1).Value="test"+"000000"+j.to_s;
         when 100..999
           userSheet.Cells(i,1).Value="test"+"00000"+j.to_s;
         else 1000..1100
          userSheet.Cells(i,1).Value="test"+"0000"+j.to_s;      
       end
     end