douxie3625 2013-03-01 13:34
浏览 26
已采纳

什么返回循环函数返回[关闭]

I am currently trying to loop through a return from a function, but I just haven't been able to figure out how to do this. It's a bit like the Wordpress loop: while (have_posts()).

That is what I am trying to do, but what do my function have to return to be while-loopable?

  • 写回答

2条回答 默认 最新

  • doufei7516 2013-03-01 13:39
    关注

    Are you just asking what have_posts() returns in this case?

    It's not "a loopable function", it's just a function. There's nothing about it that indicates a loop. It's being used in this case as the condition for a loop:

    while (have_posts())
    

    The while loop condition is expecting a boolean. Think of the statement as "while this condition is true, keep looping." So in this case have_posts() should return a boolean, true or false.

    As long as the function is returning true the loop will continue. As soon as it returns false the loop will end. The function itself has no internal knowledge of this. It's just being called over and over (each time the loop iterates).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序