是否有一个实现类似x%y == 0
的内核方法?
我认为理想情况下会出现类似10.is_evenly_divisble_by?(5)
答案 0 :(得分:2)
如果要将所有内容包装在函数中,可以使用http://ruby-doc.org/core-1.9.3/Numeric.html#method-i-modulo
private void MigrateFields()
{
var repo = ServiceLocator.Current.GetInstance<IContentRepository>();
var descendents = repo.GetDescendents(_root).Where(p => SafeGetContent(repo, p) is BasePage).Select(repo.Get<BasePage>);
foreach (var basePage in descendents)
{
BasePage writeablePage = (BasePage)basePage .CreateWritableClone();
if (basePage.SomeBlock == null)
basePage.SomeBlock = new SomeBlock ();
if (string.IsNullOrWhiteSpace(basePage.SomeBlock.Field1))
{
basePage.SomeBlock.Field1 = basePage.Field1;
}
DataFactory.Instance.Save(writeablePage, SaveAction.Publish, AccessLevel.NoAccess);
}
}