Matlab equivalent to calling inside static class

前端 未结 2 597
礼貌的吻别
礼貌的吻别 2020-12-18 05:55

Confer the following code:

classdef highLowGame
    methods(Static)
        function [wonAmount, noGuesses] = run(gambledAmount)
            noGuesses = \'so         


        
2条回答
  •  春和景丽
    2020-12-18 06:31

    Not an answer to your question directly, but it's worth noting that you can also put "local functions" after the end of your classdef block in your class.m file, and these behave like private static methods, but you do not need to invoke them using the class name. I.e.

    % myclass.m
    classdef myclass
      methods ( Static )
        function x = foo()
          x = iMyFoo();
        end
      end
    end
    function x = iMyFoo()
      x = rand();
    end
    % end of myclass.m
    

提交回复
热议问题