Access denied, Please sign in and make sure you have proper permission.

其他 对于简单脚本,感觉 perl 写得舒心一点

crella95 · September 27, 2021 · Last by ThxFly replied at November 01, 2021 · 728 hits

编程水平仅限于减小重复操作的工作量,回到 perl 这种主要面向过程的思维真好

不美丽。。。读起来心累。。。

1 Floor has deleted

ruby 最 happy 除了嵌套的 end 太多容易串行


module Web
  module Controllers
    module Home
      class Index
        include Web::Action
        def call(params)
              print  开始写代码"
              if    params  
             else   
              end 
        end
      end
    end
  end
end

就怕写完了过几天自己都看不懂

Reply to tablecell

这个代码写的。。。就好像专门和老师对着干似的 😀

.net core6 也可以不要类了

就是那个比 php 还恶心的 perl?

8 Floor has deleted
9 Floor has deleted

Ruby 自带 eval() 函数:

12 Rby> $ufm = '2*(3+5.2/(1-6.5))';
13 Rby> eval $ufm
=> 4.109090909090909

11 Floor has deleted
12 Floor has deleted
Reply to tablecell

可以这样写,就是 rubocop 的风格走偏了 (https://rubystyle.guide/#namespace-definition),没有因地制宜. 实际业务编程中,我们根本就不会去定义 Web、Controllers、Home 范围内的常量。

class Web::Controllers::Home::Index
  include Web::Action
  def call(params)
      print  "开始写代码"
      if  params  
      else   
      end 
   end
end

同理 Rails 的控制层嵌套也应写成这样,没有任何损失. 因为根本就不会去定义 Api, V1 级别的控制器常量,所以没有任何影响. 目前我就要求自己项目的人这样写,层级越少,越不容易达到每行 80 个字符的限制。

class Api::V1::UsersController < Api::V1::BaseController
   ......
end
crella95 closed this topic. 16 Oct 13:56
crella95 reopened this topic. 04 Jul 19:32
crella95 closed this topic. 04 Jul 19:33
You need to Sign in before reply, if you don't have an account, please Sign up first.